Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic In TabbedDiagramView, I have to right-click a node before I can delete it with Del key. (Read 2133 times)
Centron
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Feb 11th, 2015
In TabbedDiagramView, I have to right-click a node before I can delete it with Del key.
Mar 5th, 2015 at 11:01am
Print Post  
As the title says. Steps to reproduce:

- Have a default TabbedDiagramView named diag in the UI:

Code
Select All
<diag:TabbedDiagramView Name="diag" /> 



- In the designer code-behind, add to the constructor:

Code
Select All
        public MainWindow()
        {
            InitializeComponent();
            diag.Document = new DiagramDocument();
        } 



- At runtime, add a page to the document via the + button.
- Draw the default rounded rectangle, select and try to delete with Del key. It doesn't work.
- Select a rectangle and right-click anywhere in the diagram, then it can be deleted with the Del key.
- If you right-click and then select a new node, it again cannot be deleted until you right-click beforehand.

Is there any workaround to this behvaiour? Am I missing something?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: In TabbedDiagramView, I have to right-click a node before I can delete it with Del key.
Reply #1 - Mar 5th, 2015 at 1:58pm
Print Post  
Hi,

The template of the TabbedDiagramView contains a ScrollViewer, which prevents the diagram from receiving focus when the user clicks with the left mouse button. This can be circumvented by setting the Focusable property of the ScrollViewer to false. You can reach the ScrollViewer from any DiagramPage object by crawling up the visual tree. For example, you can do that when a new page is added to the document via the '+' button:

Code
Select All
diag.PageAdded += (s, e) =>
{
	e.DiagramPage.Loaded += (s1, e1) =>
	{
		var parent = VisualTreeHelper.GetParent(e.DiagramPage);
		while (parent != null && !(parent is ScrollViewer))
			parent = VisualTreeHelper.GetParent(parent);
		if (parent is ScrollViewer)
			((ScrollViewer)parent).Focusable = false;
	};
}; 


An alternative approach would be to replace the entire ControlTemplate of the TabbedDiagramView with a copy of the original template where the Focusable property of the ScrollViewer is set to false.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Centron
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Feb 11th, 2015
Re: In TabbedDiagramView, I have to right-click a node before I can delete it with Del key.
Reply #2 - Mar 5th, 2015 at 3:12pm
Print Post  
Thanks, that works.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint