This is a very simple case
I want to click on the button, then change the itself position
the visual studio prompt me that is a public property, and the type is double. Why I cannot change the value? And it does not provide any method let me change the top property, so how I can change the property?
<Button C开发者_如何学Goontent="Button" Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="0,0,0,0" Name="Button1" VerticalAlignment="Top" Width="75" Grid.Row="1" />
MsgBox(Button1.Margin.Top)
Button1.Margin.Top = 10
You can't set each margin individually, but you can set the button margin to a new thickness and hardcode 10 as the top margin while leaving the other values untouched:
Button1.Margin = New Thickness(Button1.Margin.Left, 10, Button1.Margin.Right, Button1.Margin.Bottom)
If you want to move the button around don't use Margin, it's not made for that intent.
Instead, place your button in a Canvas, then you can set Canvas.Top/Bottom/Left/Right to move your button around (they are attached properties).
精彩评论