C# WPF拖放,用户控件变得无响应
我正在两个ListBox项之间进行拖放操作,其中包含一个UserControl、ClaimSectionTemplate作为集合中填充源ListBox的项的DataTemplateC# WPF拖放,用户控件变得无响应,c#,wpf,C#,Wpf,我正在两个ListBox项之间进行拖放操作,其中包含一个UserControl、ClaimSectionTemplate作为集合中填充源ListBox的项的DataTemplate <ListBox Margin="13,12,12,12" Name="NewSections" Grid.Column="1" AllowDrop="True" Drop="NewSections_Drop"> <ListBox.ItemTemplate&g
<ListBox Margin="13,12,12,12" Name="NewSections" Grid.Column="1" AllowDrop="True" Drop="NewSections_Drop">
<ListBox.ItemTemplate>
<DataTemplate>
<me:ClaimSectionTemplate />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
现在我在ClaimSectionTemplate、AddField和RemoveField上有两个按钮,它们分别在ClaimSectionTemplate用户控件中显示的ClaimSection对象的子集合中添加和删除字段
<ListBox Margin="13,12,12,12" Name="NewSections" Grid.Column="1" AllowDrop="True" Drop="NewSections_Drop">
<ListBox.ItemTemplate>
<DataTemplate>
<me:ClaimSectionTemplate />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
因此,当我将一个ClaimSection放入目标列表框时,原始对象将变得无响应,不再允许我与用户控件交互
<ListBox Margin="13,12,12,12" Name="NewSections" Grid.Column="1" AllowDrop="True" Drop="NewSections_Drop">
<ListBox.ItemTemplate>
<DataTemplate>
<me:ClaimSectionTemplate />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
主窗口.Xaml
<ListBox Margin="13,12,12,12" Name="NewSections" Grid.Column="1" AllowDrop="True" Drop="NewSections_Drop">
<ListBox.ItemTemplate>
<DataTemplate>
<me:ClaimSectionTemplate />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
ClaimSectionTemplate.xaml
<ListBox Margin="13,12,12,12" Name="NewSections" Grid.Column="1" AllowDrop="True" Drop="NewSections_Drop">
<ListBox.ItemTemplate>
<DataTemplate>
<me:ClaimSectionTemplate />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
发布ExistingSections对象的代码,以及奇怪的对象ClaimSectionsNew和ClaimSectionsExisting。它们看起来很可疑,我需要完整的代码来运行和检查。ClaimSectionsNew和ClaimSectionsCiting只是两个视图模型,它们包装了一个ObservableCollections,并抽象了Add和Remove方法,以避免覆盖原始Collections。奇怪的是,我创建了自己的项目,拖放也可以很好地工作。发布所有型号的完整代码。