Selecting TextBlock in the node


Can we make a TextBlock selectable and also have it highlighted once it is selected? What are my options for the same? I tried searching for it in the API documentation but could not find a reference.

Also, the TextBlock is currently in a Panel which is inside a Node and once I click on TextBlock, I don’t want the panel/Node to be selected. Can we achieve that behavior?

Will really appreciate your help on this.

Thank you,

You can set Node.selectable to false on your Node template, if you really do not want any node to be selected.

But maybe you want to allow selection but do not want to show that a node is selected – instead, set Node.selectionAdorned to false.

Yet perhaps you want to highlight just the TextBlock when the node is selected. Instead of either of the above settings, set the to a name of your choosing and set Node.selectionObjectName to that name.

Hi Walter,

You are correct. I want to show the TextBlock selection but do not want that node is selected. I tried using the Node.selectionAdorned property and it is working fine as expected but I am not able to highlight/select the TextBlock using the above mentioned properties. Is there any other alternative?

Also, can we add an adornment to TextBlock in order to show it as Selected?

The latter question is answered by setting Node.selectionObjectName.

For the former question, I still do not understand what you really want. Do you want the user to be able to select some text, rather than a TextBlock?

If it is a TextBlock, then besides Node.selectionObjectName, you could change the appearance of the TextBlock. Easiest would be to change the TextBlock.background and/or the TextBlock.stroke. Please read