0

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.

laserman
  • 233
  • 2
  • 10
  • +1 for the complete example. same problem, different issue. Based on your example, we were missing the xaml `ActiveContent` binding. – Metro Smurf Aug 13 '22 at 22:01

1 Answers1

0

I forgot to derive the class from INotifyPropertyChanged:

class DXFViewerViewModel:INotifyPropertyChanged

Now it works.

laserman
  • 233
  • 2
  • 10