Hi,
All aspects of the ShapeNode size and location are controlled by its Bounds property. If you want to modfiy the size, but keep the node anchored to the right, you need to change not only the width, but set a new location too - the new location will be offset by the difference between the new and the old size. For example, if you increase the width by 10, you need to move the location with 10 to the left to keep the node right anchored.
var offset = newWidth - node.Bounds.Width;
var newBounds = new Rect(node.Bounds.X - offset, node.Bounds.Y, newWidth, node.Bounds.Height);
node.SetBounds(newBounds, true, true);
For the image, I already explained how to maintain its size in my previous post. If you can modify the size of your image to be what you need to be seen inside the node - the effect from your screen shot can be achieved just by setting
node.ImageAlign to
ImageAlign.BottomRight. If you can't modify the size of the image, set
node.ImageAlign to
ImageAlign.Fit and use
node.ImagePadding to restrict the image to your needed bounds. For example, if your node has a size of 50 by 50 and you need your image to have size 40 by 40 - set
node.ImagePadding = new Thickness(10, 10, 0, 0);. That will have the same effect.
Regards,
Lyubo,
MindFusion