Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In my AvalonDock DockingManager the Property ActiveContent does not update the active tab when I load a new document. I have a ActiveDocument Property like this:

     private DocumentViewModel m_activeDocument;

    public DocumentViewModel ActiveDocument
    {
        get { return m_activeDocument; }
        set
        {
            m_activeDocument = value;
            OnPropertyChanged("ActiveDocument");
        }
    }

I have an OnPropertyChanged Method like this:

    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged(string propertyChanged)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyChanged));
    }

I have an observable collection Documents like this:

    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;
        }
    }

and I call the dockingmanager like this:

    <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}}"
                       >

When I set the ActiveDocument to the just loaded documents like this:

            var ld = new DocumentViewModel { Title = fileName, PltModel = tmp };
            m_documents.Add(ld);
            ActiveDocument = ld;

the document does not show up in front.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
194 views
Welcome To Ask or Share your Answers For Others

1 Answer

I forgot to derive the class from INotifyPropertyChanged:

class DXFViewerViewModel:INotifyPropertyChanged

Now it works.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...