【发布时间】:2015-10-24 11:48:29
【问题描述】:
我在 WPF 中创建了一个小程序,单击一个按钮并弹出一个文本框。我想让这个可移动 - 拖放。
在代码中,我为名为@987654321@ 的文本框创建了一个对象,并使用了命令x.AllowDrop = true;,但没有成功。
我尝试过 MSN、Youtube 等来源,但都没有成功。
private void button1_Click_1(object sender, RoutedEventArgs e) {
TextBox x = new TextBox();
x.Name = "new_textboxqq";
x.TextWrapping = TextWrapping.Wrap;
x.Text = "asfsadfasfsadfasff";
x.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
x.Background = Brushes.Yellow;
x.AcceptsReturn = true
x.Margin = new Thickness(5, 10, 0, 0);
x.AllowDrop = true;
HouseCanvas.Children.Add(x);
this.AllowDrop = true;
Canvas.SetLeft(x, 20);
Canvas.SetTop(x, 20);
}
【问题讨论】: