在代码隐藏WinRT中更改角色Canvas.Left和Canvas.Top

时间:2014-02-02 19:29:20

标签: c# wpf xaml canvas winrt-xaml

<Button x:Name="PlayButton" Content="Play" Canvas.Left="570" Canvas.Top="36" Height="51" Width="202" Background="#FF8898F9" />

如何在代码中更改PlayButton的Canvas.Top和Canvas.Left属性?

2 个答案:

答案 0 :(得分:21)

Canvas类有SetTopSetLeft个静态方法来设置这些附加属性:

Canvas.SetTop(PlayButton, 36);
Canvas.SetLeft(PlayButton, 750);

答案 1 :(得分:4)

Canvas.SetLeft(PlayButton, 100);
Canvas.SetTop(PlayButton, 50);