Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Deleted nodes not disappearing (Read 392 times)
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 40
Location: Seattle
Joined: Feb 6th, 2017
Deleted nodes not disappearing
Jun 25th, 2024 at 1:33am
Print Post  
I'm having a strange issue with one of my Diagrams while upgrading from 3.5 to 4.1.

When I delete a node (either programmatically or with the delete key), the node doesn't actually disappear. If I do another operation, such as move another node, resize the window, zoom in/out, then the drawing updates and the node disappears.  My Diagram uses mainly TemplatedNodes and a few ShapeNodes. The ShapeNodes disappear when deleted, but not the TemplatedNodes.  Any attached Links do disappear.
I have another Diagram in my app, and the TemplatedNodes on that Diagram disappear with no problems. The two Diagrams use completely different templates for the nodes.

Do you have any suggestions on what I should dig into to figure out why just this one Diagram doesn't redraw?  Calling InvalidateVisual() on both the Diagram or the DiagramView doesn't do anything. The TemplatedNode is actually gone from the Diagram's Nodes collection, so there's nothing to call Repaint() on. My Diagram is inside a DiagramView.

Cheers.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: Deleted nodes not disappearing
Reply #1 - Jun 25th, 2024 at 6:43am
Print Post  
If overriding OnRemove in a custom node class, please call base.OnRemove. If handling diagram.ItemRemoved event, make sure the handler is not throwing exceptions before DiagramPresenter's own handler executes; these could be potentially caught somewhere by the application and going unnoticed.

Otherwise try debugging Diagram.RemoveItem -> RaiseItemRemoved -> DiagramPresenter.OnItemsChanged -> VirtualizeItems call chain to see why the latter keeps the node presenter (not reaching InternalChildren.RemoveAt line).

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 40
Location: Seattle
Joined: Feb 6th, 2017
Re: Deleted nodes not disappearing
Reply #2 - Jun 25th, 2024 at 8:26pm
Print Post  
I figured out my problem based on your advice.

I see that in VirtualizeItems(), the InternalChildren collection is where the node should be removed.  But what's happening is that in my NodeDeleted event handler I'm running some code that causes a completely different UserControl to run its own MeasureOverride() code, and perhaps because that UserControl is beside the Diagram, it's causing the Diagram's MeasureOverride() function to also run right away.  So then only after the Diagram's MeasureOverride() function runs is when OnRemove() in DiagramItem gets to run, and "standalone" is set to true.  Then finally InvalidateMeasure is called on the Diagram, but I think that since it was already run accidentally by my event handler, WPF decides it doesn't need to be remeasured, and therefore VirtualizeItems() doesn't run again, and the node never gets removed from InternalChildren.

My solution is to delay the MeasureOverride() on my other UserControl, so that I can make sure the Diagram's MeasureOverride() runs at the correct time.

Thanks!
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: Deleted nodes not disappearing
Reply #3 - Jun 26th, 2024 at 6:36am
Print Post  
It could be due to WPF marking the measures as part of same layout pass until Arrange methods are called. In what manner are you managing to get MeasureOverride called immediately? If that can be easily done by application's code, our developers will consider running VirtualizeItems synchronously for deleted items.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 40
Location: Seattle
Joined: Feb 6th, 2017
Re: Deleted nodes not disappearing
Reply #4 - Jun 26th, 2024 at 8:39pm
Print Post  
I'm calling UpdateLayout() from the code-behind of my UserControl.  UpdateLayout() is inherited from UIElement.  Again, this UserControl does not contain the Diagram; it simply sits next to another UserControl that contains the Diagram.

When a node is deleted from the Diagram, my NodeDeleted event handler calls into my viewmodel to remove an element from an ObservableCollection.  And then the non-Diagram UserControl reacts to the collection being changed, and that's where UpdateLayout() is called.

Cheers,
Joel.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: Deleted nodes not disappearing
Reply #5 - Jun 28th, 2024 at 7:12am
Print Post  
Please check if your original code works with this build -
https://mindfusion.eu/_beta/wpfdiag411.zip

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 40
Location: Seattle
Joined: Feb 6th, 2017
Re: Deleted nodes not disappearing
Reply #6 - Jun 28th, 2024 at 5:04pm
Print Post  
Yes, that works now!

Do you have a schedule for the next small release?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: Deleted nodes not disappearing
Reply #7 - Jul 1st, 2024 at 6:39am
Print Post  
We should release it this week.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint