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

iva*_*ax9 9 c# wpf xaml canvas winrt-xaml

<Button x:Name="PlayButton" Content="Play" Canvas.Left="570" Canvas.Top="36" Height="51" Width="202" Background="#FF8898F9" />
Run Code Online (Sandbox Code Playgroud)

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

dko*_*ozl 22

Canvasclass has SetTopSetLeft静态方法设置这些附加属性:

Canvas.SetTop(PlayButton, 36);
Canvas.SetLeft(PlayButton, 750);
Run Code Online (Sandbox Code Playgroud)


Roh*_*ats 6

Canvas.SetLeft(PlayButton, 100);
Canvas.SetTop(PlayButton, 50);
Run Code Online (Sandbox Code Playgroud)