How to Make a Selected Node With a UIElement
Questions & AnswersSummary
Description
In yFiles WPF by default selected nodes that consist of interactive UIElements (TextBoxes etc.) don't react to mouse input anymore. As soon as the node gets selected, the selection indicator blocks input to the node's UIElements. This is because the rendering of the selection is done using a rectangle that has a transparent fill and all mouse input is delegated to that transparent fill by the WPF input system.
This is intentional because otherwise basic interaction like moving a selected node would not work because instead of moving the node with a mouse drag instead e.g. text would become selected because the a text box would recognize the mouse drag as a text selection gesture.
Of course there are situations when the default behavior is unwanted, so one of the following approaches should be chosen to disable that behavior
Disable selection rendering alltogether
In situations where the nodes indicate their selection state using a different scheme (e.g. by changing their color) or it is not necessary to show the selection state at all, the selection rendering can be disabled completely using the SelectionIndicatorManager property of the SelectionIndicatorManager:
graphControl.SelectionIndicatorManager.Enabled = false;Change the default default template for rectangular selections
yFiles WPF uses a resource to determine the brush to use by default for rectangular
selection indicators. Simply redeclaring the resource in one of the ancestors of the graph control (or the control itself) tonullgets rid of the fill:<Window.Resources> <x:Null x:Key="{x:Static y:RectangleIndicatorInstaller.SelectionTemplateKey}"/> </Window.Resources>