0

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.

enter image description here

enter image description here

<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

Ronald Araújo
  • 1,395
  • 4
  • 19
  • 30
  • Simply subtract the delta from the top. – TaW Jul 22 '14 at 20:05
  • Does [this question help](http://stackoverflow.com/questions/1185948/how-to-change-x-y-origin-of-canvas-to-bottom-left-and-flip-the-y-coordinates)? – gunr2171 Jul 22 '14 at 20:05
  • Is the Rectangle on a Canvas? Or in a Grid? Or other? – Tim Jul 22 '14 at 20:06
  • After re-reading, it seems to me (I can be wrong of course) that you think that Y-axis is directed from bottom to top. However, it is vice versa. So to say the "origin" of a rectangle is its up left corner, not the bottom left one. – AlexD Jul 22 '14 at 21:04
  • @AlexD I would like to change that! I want to set the origin on the left side in parde low. Is it possible? – Ronald Araújo Jul 23 '14 at 11:36
  • 1
    @RonaldAraújo Try ``, see http://msdn.microsoft.com/en-us/library/aa348048.aspx. – AlexD Jul 23 '14 at 16:27

1 Answers1

1

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.

Tim
  • 14,999
  • 1
  • 45
  • 68