wpf - 处理重叠的拖动形状
问题描述
它可以相互连接以制作新的块。但问题是,当我将两个 [Blue] Shape 拖入 [If] Shape 时,我无法再拖动 [Blue],导致 [If] Shape 折叠并导致 [Blue] Shape 无法交互.
这是我的代码:
形状的定义
<UserControl x:Class="SampleCode.ActionShape"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SampleCode"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d" >
<UserControl.Resources>
<local:ColorToBrushConverter x:Key="colorToBrushConverter"/>
<local:ThicknessConverter x:Key="thicknessConverter"/>
</UserControl.Resources>
<Grid>
<Path Data="{Binding SvgData}"
Fill="{Binding Color, Converter={StaticResource colorToBrushConverter}}"
Cursor="Hand">
</Path>
<TextBlock Foreground="{Binding TextColor, Converter={StaticResource colorToBrushConverter}}" FontSize="{Binding FontSize}" Margin="{Binding MarginText}" Text="{Binding Text}"></TextBlock>
</Grid>
</UserControl>
主窗口.xaml
<Window x:Class="SampleCode.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SampleCode"
Title=""
Width="1400"
Height="800"
Loaded="Window_Loaded">
<Window.Resources>
<local:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
<DataTemplate DataType="{x:Type local:BaseShapeMVVm}">
<local:ActionShape AllowDrop="True" MouseDown="Rectangle_MouseDown" MouseMove="Rectangle_MouseMove" MouseUp="Rectangle_MouseUp"></local:ActionShape>
</DataTemplate>
</Window.Resources>
<Window.DataContext>
<local:ViewModel />
</Window.DataContext>
<Grid>
<TreeView Name="ListBox" ItemsSource="{Binding Rectangles}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter
Property="Canvas.Left" Value="{Binding X}"/>
<Setter
Property="Canvas.Top" Value="{Binding Y}"/>
</Style>
</ItemsControl.ItemContainerStyle>
</TreeView>
</Grid>
</Window>
你能给我一些关于这个问题的建议吗?我很兴奋
解决方案
推荐阅读
- javascript - 如何在 freemysqlhosting.net 上将长数据传递到 mySql 数据库
- python - Python:如何通过无效的分隔符分割字符串<0x0c>
- c++ - webRTC c++中有自定义音频源的功能吗?
- servlets - 文件究竟何时传输到服务器?
- javascript - 连接两个 gatsby 节点
- android - 获取值 ($field) 时,Kotlin 属性处于循环中
- conv-neural-network - YOLO 的输出是如何编码的
- javascript - 在更改其属性后渲染数组项
- css - 如何在跨度标签内居中对齐锚标签?
- docker - 尝试从 docker swarm 中的 kafka 代理捕获数据时失败