AvalonDock DockingManager ActiveContent不会更新

问题描述 投票:0回答:1

在我的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;

该文档未显示在前面。

c# .net wpf avalondock
1个回答
0
投票

我忘了从INotifyPropertyChanged派生该类:

class DXFViewerViewModel:INotifyPropertyChanged

现在可以使用。

© www.soinside.com 2019 - 2024. All rights reserved.