I have a diagram in a TabItem with my model’s NodesSource bound to an ObservableCollection. When I add items to the collection, the diagram doesn’t refresh itself until I click onto a different tab and then go back to that tab.
How can I get the diagram to update itself? The NodesSource is definitely updated just fine, but the display isn’t. I tried using DoNodeAdded but it didn’t have any effect.
There’s not much more to it. I have a TabControl with several tabs in it. One of the tabs has a Diagram with a TreeModel with the TreeModel.NodesSource bound to an ObservableCollection of my own objects. I can import items into my application and when I do I add them to the ObservableCollection. The collection is up to date but the Diagram doesn’t display the new nodes until you force a redraw, like by zooming in, switching to another tab and back, panning, etc.
If you (temporarily) change your app so that the Diagram is not inside a Tab, does it update correctly as you add node data to your model’s NodesSource collection?
No, it still does not update until I do something manually to redraw it. I am just using the built-in WPF TabControl. My TabItems are created from an ObservableCollection of MyTabItems bound to the TabControl.ItemsSource with the following ContentTemplate:
where View is a UserControl containing, for the tab in question, the Diagram.
I didn’t know I had to use these methods. That was it!
Why does the Diagram use such a weird string-based update process instead of just respecting ObservableCollections to update itself automatically? It makes it feel a lot more like WinForms than WPF to me.