【发布时间】:2016-06-24 11:02:54
【问题描述】:
我正在尝试使用鼠标和通过代码移动和重新定位元素。但我想我错过了什么或做错了什么。所以我构建了一个小示例应用程序。它只是一个带有此 MainWindow 功能的空 wpf 应用程序
public MainWindow()
{
InitializeComponent();
Label lText = new Label();
lText.Content = "this is my test label";
lText.Height = 50;
lText.Width = 50;
lText.Background = Brushes.Aqua;
// do I really need to do this?
lText.VerticalAlignment = System.Windows.VerticalAlignment.Top;
lText.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
// this part already fails
Canvas.SetTop(lText, 20);
Canvas.SetLeft(lText, 10);
this.Content = lText;
}
【问题讨论】:
-
@Clemens:为什么要评论
标签: wpf canvas mouse controls move