这看起来很简单,但我想不通!在这里寻求一点帮助。我有一堆 ListBoxItems,并希望它们在丢弃时转储不同的文本。
是否可以有一个基于下拉事件的 ListBoxItem 名称的 if 语句?
XAML:
<ListBoxItem x:Name="ActionItem">
<Image Source="Action.png" Height="60" Width="60" ToolTip="Action"/>
代码背后:
private void DropImage(object sender, System.Windows.DragEventArgs e)
{
{
ImageSource image = e.Data.GetData(typeof(ImageSource)) as ImageSource;
Image imageControl = new Image() { Width = image.Width, Height = image.Height, Source = image };
Canvas.SetLeft(imageControl, e.GetPosition(this.MyCanvas).X);
Canvas.SetTop(imageControl, e.GetPosition(this.MyCanvas).Y);
this.Canvas.Children.Add(imageControl);
TextBox.Text = ("This is a test!");
}
我应该将我的 listboxitems 转换为字符串,然后为每个 or 执行 if 语句吗?谢谢