Data Attribute in One Node Changes ContextMenu of Another Node

The context menu is being shared by all of the nodes that use that template (and maybe by other templates too – that depends on how you defined the contextMenu).

So as long as the node data doesn’t have a data.disableNotes property (or if the value is undefined) the TextBlock.stroke will remain at its initial value of “black”.

Then the context menu is shown for a node data object that does have a property value for data.disableNotes, and the Binding is evaluated and its conversion function returns either “lightgray” or “black”. (Assuming this.colors.textColor hasn’t changed.) In the case for id===12, that would be “lightgray”.

But then if you show the context menu for a node such as id===21, that Binding is not evaluated because the data.disableNotes property is not present or is undefined. So the TextBlock.stroke remains whatever it had been – “lightgray” in your case.

The problem is that with no value for that data property, bindings that use that property as a source do not evaluate. Furthermore, whatever had been the initial value for TextBlock.stroke has been lost, having been overwritten any number of times.

The obvious solution is to make sure that the “disableNotes” property is defined on each node data object.

If that is not feasible, you could customize the showing or the hiding of the context menu to reset the TextBlock.stroke to “black”. For example you could override ContextMenuTool.hideContextMenu to see if the ContextMenuTool.currentContextMenu is one that you want to reset. If so, reset it. Then call the super method for the standard behavior.