Change background for nodes in group

How can I change the background of all nodes in a group when group node is selected? I know how to change the background of Group node but I want to keep that transparent and let user find out nodes in group with different background color of all the nodes contained within a single group.

Have you seen in the samples how you can data-bind a brush to whether the Node or Link IsSelected? Look for “{Binding Path=Node.IsSelected, …” or “{Binding Path=Part.IsSelected, …”.

I haven’t tried this, but you could try “{Binding Path=Part.ContainingSubGraph.IsSelected, …”. But I’m not entirely confident that that will work, because the nature of data-binding isn’t completely well defined, and is subtly different between Silverlight and WPF.

Oh, and if that doesn’t work, you can always define your own Group subclass and override Part.OnIsSelectedChanged to call the base method and then do whatever you want with the Group.MemberNodes.

In order for the PartManager to automatically make use of your Group-inheriting class, you’ll need to override PartManager.MakeNodeForData. Here’s the definition:

protected virtual Node MakeNodeForData(Object nodedata, IDiagramModel model, bool isgroup, bool islinklabel, String category, DataTemplate templ) { Node node = (isgroup ? new Group() : new Node()); PartBinding data = new PartBinding(node, nodedata); node.Content = data; node.DataContext = data; node.ContentTemplate = templ; node.IsLinkLabel = islinklabel; if (category != null && category != "") { if (node.Category != category) node.Category = category; } return node; }
Just construct your custom Group class instead of the Group constructor.