Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF拖放,用户控件变得无响应_C#_Wpf - Fatal编程技术网

C# WPF拖放,用户控件变得无响应

C# 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项之间进行拖放操作,其中包含一个UserControl、ClaimSectionTemplate作为集合中填充源ListBox的项的DataTemplate

        <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。奇怪的是,我创建了自己的项目,拖放也可以很好地工作。发布所有型号的完整代码。