wpf 在 WinRT 代码隐藏中更改属性 Canvas.Left 和 Canvas.Top

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21515135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 10:41:37  来源:igfitidea点击:

Change propety Canvas.Left and Canvas.Top in codebehind WinRT

c#wpfxamlcanvaswinrt-xaml

提问by ivamax9

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

How change Canvas.Top and Canvas.Left property of PlayButton in the code?

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

回答by dkozl

Canvasclass has SetTopand SetLeftstatic methods that set these attached properties:

Canvas类有SetTopSetLeft用于设置这些附加属性的静态方法:

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

回答by Rohit Vats

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