tags:

views:

22

answers:

2

Hi. Here is my code :

                    <Image x:Name="Layer_22_copy" Height="542" Canvas.Left="16" Opacity="0.522" Source="gammon2_Images\Layer 22 copy.png" Canvas.Top="13" Width="315"/>

how can i change position of this image on Code Behind? i am new in WPF. thank you.

+2  A: 
Layer_22_copy.SetValue(Canvas.TopProperty, newTopValue);
Layer_22_copy.SetValue(Canvas.LeftProperty, newLeftValue);
Martin Harris
+1  A: 

You can set the Margin Property like

Layer_22_copy.Margin = new Thickness(10, 30, 0, 0);
Avatar
what's deference between margin and canvas.left and right property?
shaahin
No big difference. If, you hosted the image inside a canvas you could use the Canvas.Left or Top or Right or Bottom.But, you can set margin even if you hosted it in Grid or in any custom panel. Also, It will reduce the number of lines. :)
Avatar