Binding Part.IsSelected


As the Part.IsSelected property is readonly, I can’t perform a binding with my data structure.

Have you an other “binding” way to do this ?

I’d like the following:

<go:SpotPanel go:Part.IsSelected={Binding Path=Data.MyItem.IsSelected, Mode=TwoWay}>

because in some scenario, i select item in the code.

I will be simpler to bind otherwise making event scenario.


Part.IsSelected is definitely read-write. It’s a dependency property, so you can data-bind it.

However, it’s a regular dependency property on Part, not an attached dependency property on the root FrameworkElement of the Part’s visual tree (i.e. on Part.VisualElement).

I haven’t had the time to try this, but perhaps you could override PartManager.MakeNodeForData to call the base method and then establish programmatically the Binding that you want.

Great idea. It works as wanted.

protected override Node MakeNodeForData(object nodedata, IDiagramModel model, bool isgroup, bool islinklabel, string category, DataTemplate templ)
            Node oNode =  base.MakeNodeForData(nodedata, model, isgroup, islinklabel, category, templ);
            if (oNode != null && ((QD_Node)oNode.Data).HasItem)
                Binding binding = new Binding() { 
                    Path = new PropertyPath("Data.Item.ExtendedProperties[IsQDSelected]"),
                    Converter = (IValueConverter)this.TryFindResource("convObjectBoolean"),
                    Mode = BindingMode.TwoWay
                oNode.SetBinding(Part.IsSelectedProperty, binding);                  
            return oNode;



It work’s as needed for reloaded diagram and node programmatically created, but MakeNodeForData is not called when node is created using drag/drop from palette…

Could you tell me where set the same logic for these nodes ?


I just tried adding an override of PartManager.MakeNodeForData to the MyPartManager class in the FlowChart sample. It’s definitely being called for external drag-and-drop drops.

Perhaps you didn’t replace the standard Diagram.PartManager with your custom one for that particular Diagram?

ok I will try the modification in your sample on monday.

I’m sure I use my custom PartManager for diagram (my binding works for node loaded by diagram)
should I use the same for palette ?


Cross-Diagram drag-and-drop uses the target Diagram.DraggingTool for the behavior you see in the target.

So you don’t need to customize the Palette for this task.