Reputation: 1479
The figure below shows me changing two values for height. When I decrease the height instead of the figure decreasing from top to bottom the opposite happens.
<Rectangle Fill="#DBDBDB" HorizontalAlignment="Left" Height="100" Margin="547,607,0,0" Stroke="Silver" StrokeThickness="2" VerticalAlignment="Top" Width="100" RenderTransformOrigin="0,0.97" />
I just need to know how to set X and Y
Upvotes: 0
Views: 1080
Reputation: 15227
If your rectangle happens to be on a Canvas, you can make use of the Canvas.Right and Canvas.Bottom
<Canvas>
<Button Click="Button_Click">Shrink It a Bit</Button>
<Rectangle x:Name="_Rectangle" Canvas.Bottom="20" Canvas.Right="20"
Fill="Black" Height="50" Width="50" />
</Canvas>
So now if you shrink it:
_Rectangle.Height = _Rectangle.Height - 5;
_Rectangle.Width = _Rectangle.Width - 5;
you'll notice that it shrinks from the top and left. You can use the appropriate combinations of Top/Bottom, Right/Left to get the effect you desire.
Upvotes: 1