c# - AvalonDock DockingManager ActiveContent 不更新
问题描述
在我的 AvalonDock DockingManager 中,当我加载新文档时,属性 ActiveContent 不会更新活动选项卡。我有一个这样的 ActiveDocument 属性:
private DocumentViewModel m_activeDocument;
public DocumentViewModel ActiveDocument
{
get { return m_activeDocument; }
set
{
m_activeDocument = value;
OnPropertyChanged("ActiveDocument");
}
}
我有一个这样的 OnPropertyChanged 方法:
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyChanged)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyChanged));
}
我有一个可观察的集合文档,如下所示:
private ObservableCollection<DocumentViewModel> m_documents = new ObservableCollection<DocumentViewModel>();
private ReadOnlyObservableCollection<DocumentViewModel> m_readonlyDocuments = null;
public ReadOnlyObservableCollection<DocumentViewModel> Documents
{
get
{
if (m_readonlyDocuments == null)
m_readonlyDocuments = new ReadOnlyObservableCollection<DocumentViewModel>(m_documents);
return m_readonlyDocuments;
}
}
我这样称呼对接管理器:
<xcad:DockingManager Grid.Row="2"
AllowMixedOrientation="True"
BorderBrush="Black"
BorderThickness="1"
Theme="{Binding ElementName=_themeCombo, Path=SelectedItem.Tag}"
DocumentsSource="{Binding Documents}"
ActiveContent="{Binding ActiveDocument, Mode=TwoWay, Converter={StaticResource ActiveDocumentConverter}}"
>
当我将 ActiveDocument 设置为刚刚加载的文档时,如下所示:
var ld = new DocumentViewModel { Title = fileName, PltModel = tmp };
m_documents.Add(ld);
ActiveDocument = ld;
文件没有出现在前面。
解决方案
我忘了从 INotifyPropertyChanged 派生类:
class DXFViewerViewModel:INotifyPropertyChanged
现在它起作用了。
推荐阅读
- avro - Avro 模式中 Map 的 AsyncAPI yaml 等效表示是什么
- hierarchical-bayesian - 贝叶斯层次聚类
- django - 如何为队列中的用户过滤对象
- python - 如何避免使用 Python 的 Selenium Webdriver 中的 SSL 认证错误?
- excel - Excel vba使用字典循环提取数据
- python - 当您的计算机处于睡眠模式时,您可以让它运行 python 吗?
- ios - 如何通过 API 使用后台任务?
- arrays - 在laravel中检索与外键匹配的所有数据
- javascript - 附加后如何从子类中删除父类样式
- azure - 使用 MSI 与 Azure 文件共享的连接不起作用