Skip to main content
 首页 » 编程设计

c#之AvalonDock : When using DocumentPane binding, 新 DocumentContent 项目的选项卡不可单击

2024年02月23日12JeffreyZhao

我正在尝试使用下面的 xaml 将 DocumentPane 绑定(bind)到属性 ObservableCollection DocumentContent。

<ad:DocumentPane Name="documentPane" ShowHeader="True" ItemsSource="{Binding Path=DocumentContent, Mode=OneWay}"></ad:DocumentPane> 

我的问题是,当一个新的 DocumentContent 对象添加到 ObservableCollection 时,它会正确地将选项卡添加到 DocumentPane,但该选项卡不可单击。

在我切换到数据绑定(bind)之前,我使用的是 document.Items.Add( new DocumentContent() ),它按预期工作。

有没有人知道为什么如果通过数据绑定(bind)添加选项卡则无法点击?

请您参考如下方法:

我设法通过将绑定(bind)移动到父 DockingManager 元素来解决此问题,使用 DocumentsSource 而不是 ItemsSource。相当违反直觉,但它确实有效。