c# - 如何将列表项拖放到图像视图 (WPF)?
问题描述
我想要的是将列表项从列表框中拖放到 WPF 中的 imageView 中。
所以我有一个列表框,其中包含一些列表项,例如:circle1、circle2 和带有图片的 imageView。现在我想在这张图片上拖放一个列表项。这个列表项在这张图片上显示为一个圆圈。
这可能吗?
我的带有列表框和图像的主 WPF:
<Window x:Class="MyProject.ControlCentre.UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CLock.ControlCentre.UI"
mc:Ignorable="d"
Title="MyProject - ControlCentre" Height="391" Width="767" Icon="/Images/MyIcon.ico">
<Grid Background="#FF2B2B2B" Height="376">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="0*"/>
</Grid.RowDefinitions>
<Menu x:Name="menuControlCentre" Margin="0,0,0,311" Background="#FF2B2B2B">
<MenuItem x:Name="menuItemControlCentre" Header="_File" Foreground="White">
<MenuItem x:Name="mItemLogInCC" Header="_LogIn" Foreground="Black"></MenuItem>
<MenuItem x:Name="mItemLoadImageCC" Header="_Load Image" Foreground="Black" Click="mItemLoadImageCC_Click"></MenuItem>
<MenuItem x:Name="meItemExitCC" Header="_Exit" Foreground="Black" Click="menueItemExitControlCentre_Click"></MenuItem>
</MenuItem>
</Menu>
<ListBox x:Name="lbxCircles" Margin="10,58,562,23" Background="White" SelectionChanged="lbxDoors_SelectionChanged"/>
<Label Content="Türen:" HorizontalAlignment="Left" Margin="10,32,0,0" VerticalAlignment="Top" Foreground="White" Height="26" Width="44"/>
<Image x:Name="imgPlanOfRoom" HorizontalAlignment="Left" Height="228" Margin="247,58,0,0" VerticalAlignment="Top" Width="487"/>
<Label Content="Plan of Room:" HorizontalAlignment="Left" Margin="247,35,0,0" VerticalAlignment="Top" Foreground="White"/>
</Grid>
我尝试用 AllowDrop 之类的东西来做,但没有用。我不知道如何实现列表项转换为圆形并拖放到 imageView 上的功能。
我希望有一个人可以帮助我。
解决方案
推荐阅读
- python - 总和为一个数字但最小化标准偏差的固定长度列表
- assembly - MIPS 汇编代码计算字符串中的位数
- excel - 如何比较2张纸中的行,然后将不同的行复制到另一张纸vba
- java - 寻找退出系统或停止代码的方法
- regex - 如何为 apache nutch 正则表达式网站 URL?
- algorithm - 排名 - 最小化成对比较
- python-3.x - 使用 Python ElementTree 在 xml 存档中获取邻居元素
- react-native - 在 React Native 中按下回车时如何禁用在多行 TextInput 中插入新行
- jquery - align button on the right side
- java - 执行/测试一个类