Hi,
I’ve nearly got to grips with the programming model, but occasionally get stuck and, after spending my day trying to resolve this myself, I have to give up and ask …
Part of the graph tool that I am building requires that, if a node has any connected links, then it cannot be dropped onto a Group node. This only applies to Group nodes that are not linkableTo or LinkableFrom.
I have a number of different templates that I use for the Groups, the one below defines that it is neither linkable to or from.
<DataTemplate x:Name="PrioritizeTemplate"> <go:NodePanel Style="{StaticResource SpotPanelStyle}" go:Node.LinkableFrom="False" go:Node.LinkableTo="False" go:Part.DropOntoBehavior="AddsToGroup" > <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource TextBlockStyle}" Text="{Binding Data.Text, Mode=OneWay}" Foreground="White" /> </go:NodePanel> </DataTemplate>
When I run this code, the diagram edit honours the LinkableFrom and LinkableTo conditions, but what I need to do is, before I allow a node to be dropped onto it (I have a custom DraggingTool) - I want to check that evaluate the LinkableFrom/To properties on the Group node.
I have used the static methods on the Group/Node classes, but they always return null…
var top = this.Diagram.Panel.FindElementsAt<Group>(pt, Part.FindAncestor<Group>, px => !Diagram.SelectedParts.Contains(px), SearchLayers.Parts).FirstOrDefault(); var linkableFrom = Group.GetLinkableFrom(top); var linkableTo = Group.GetLinkableTo(top);
The above code is called during a ConsiderDragOver method. The “top” returns the Group that I am expecting - but the GetLinkableFrom/To always returns a null.
I know that it’s going to something obvious, but can’t get to the bottom of it.
On another note … How do I enable the whole surface area of the Group node to be LinkStart’able and LinkEnd’able ?