Hi there!
You need to make sure that either or both of go:Node.LinkableFrom and go:Node.LinkableTo are set to true on the port element if go:Node.PortId has been set, or on the root element if no such element has go:Node.PortId set (i.e. if the whole node is the default port element).
What sample did you start from? I have no idea of what might be in WorkflowView.xaml.*.
The WorkflowView is nearly the same as the FlowChart Example of the GoSilverlightDemo4.
<go:Diagram x:Name="workflowDiagram" DataContext="{Binding WorkflowViewModel}" Model="{Binding Path=WorkflowModel, Mode=TwoWay}" PartManager="{Binding Path=PartManager}" LinkingTool="{Binding Path=LinkingTool}" RelinkingTool="{Binding Path=RelinkingTool}"
is this a problem?
if not, Eventhandling is different like this:
....
<i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <i:InvokeCommandAction CommandParameter="{Binding ElementName=workflowDiagram,Mode=OneWay}" Command="{Binding SelectStepCommand}"/> </i:EventTrigger> </i:Interaction.Triggers>
</go:Diagram>
In general you should not try to data-bind the non-UI parts of the Diagram that are separate classes but are owned by the Diagram. That includes properties such as Diagram.PartManager and Diagram.LinkingTool.
The reason the functionality of the Diagram class has been split up into separate classes is to make them simpler and easier to customize and replace. (Subclassing controls is harder than just subclassing a Tool or the PartManager.)
But you can still make it work, I think. How do you initialize the data.PartManager and data.LinkingTool (et al) properties? Do you make sure you do not share any such instances between Diagrams? Does your LinkingTool’s CanStart method get called, and if so, does it return true?
The LinkingTool is a class named WorkflowLinkingTool, which is inherited by LinkingTool :) ( i know little confusing)
how I initialize? simple with
this.LinkingTool = new WorkflowLinkingTool
and I can’t share this instances, because there are only one Diagram^^
I didn’t know if CanStart is called, because i didn’t override this method from the base class. But what I know is, that the DoStart method isn’t called. therefore the CanStart method must return false, or there is a problem with the ToolManager because he can’t make LinkingTool its current one
I suggest that you confirm in the debugger that the Diagram.LinkingTool is indeed an instance of WorkflowLinkingTool.
If that is the case I suggest you then try an override of CanStart, just to debug whether it is called and what it returns. It requires that the LinkingTool.Diagram be your Diagram, that Diagram.isReadOnly is false, that Diagram.allowLink is true, that the Model.Modifiable is true, that the event be a left mouse button down and that FindLinkablePort() returns a port element. You can read the documentation for FindLinkablePort for more details.
i’ll try that, thank you
okay, i’ve tried it, but it doesn’t work.
workflowModel.Modifiable = true;
if (!base.CanStart()) return false; // this checks that this.IsMouseEnabled is true
if (diagram == null || diagram.IsReadOnly) return false;
if (!diagram.AllowLink) return false;
IDiagramModel model = diagram.Model;
if (model == null || !model.Modifiable) return false;
// require left button & that it has moved far enough away from the mouse down point, so it isn't a click
if (!IsLeftButtonDown()) return false;
// don't include the following check when this tool is running modally
if (diagram.CurrentTool != this) {
if (!IsBeyondDragSize()) return false;
}
FrameworkElement port = FindLinkablePort();
return (port != null);
}
okay, when im debugging
if (diagram.CurrentTool != this)if (!IsBeyondDragSize()) return false;
}
foreach (IDiagramTool tool in diagram.MouseMoveTools) { if (tool.CanStart()) {
some code.. }
break;
Look at the Diagram.MouseMoveTools list – your custom linking tool should be the first one on the list.
haha, I came exactly to the same conclusion at this moment :)
okay, Workaround doesn’t work, because the ToolManager (I’m not sure) don’t want that I make changes in the Diagram.MouseMoveTools list.
You said you did:
this.LinkingTool = new WorkflowLinkingTool
Where is this code? In a Diagram-derived class constructor?
If so, that ought to work.
But the normal way to do this is in XAML:
<go:Diagram …>
go:Diagram.LinkingTool
<local:WorkflowLinkingTool />
</go:Diagram.LinkingTool>
</go:Diagram>
In the Code behind:
public partial class WorkflowView : UserControl{ <SPAN style="COLOR: blue">public</SPAN> WorkflowView() { <SPAN style="COLOR: blue">this</SPAN>.InitializeComponent(); <SPAN style="COLOR: blue">this</SPAN>.workflowDiagram.LinkingTool = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">WorkflowLinkingTool</SPAN>(); } }</PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: ">This works, But this isn't MVVM.</PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: ">View: </PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><SPAN style="COLOR: blue"><</SPAN><SPAN style="COLOR: #a31515">go</SPAN><SPAN style="COLOR: blue">:</SPAN><SPAN style="COLOR: #a31515">Diagram</SPAN><SPAN style="COLOR: red"> x</SPAN><SPAN style="COLOR: blue">:</SPAN><SPAN style="COLOR: red">Name</SPAN><SPAN style="COLOR: blue">=</SPAN><SPAN style="COLOR: blue">"workflowDiagram"</SPAN> <SPAN style="COLOR: red"> DataContext</SPAN><SPAN style="COLOR: blue">="{</SPAN><SPAN style="COLOR: #a31515">Binding</SPAN><SPAN style="COLOR: red"> WorkflowViewModel</SPAN><SPAN style="COLOR: blue">}</SPAN><SPAN style="COLOR: blue">"</SPAN> <SPAN style="COLOR: red"> Model</SPAN><SPAN style="COLOR: blue">="{</SPAN><SPAN style="COLOR: #a31515">Binding</SPAN><SPAN style="COLOR: red"> Path</SPAN><SPAN style="COLOR: blue">=</SPAN><SPAN style="COLOR: blue">WorkflowModel</SPAN><SPAN style="COLOR: blue">,</SPAN><SPAN style="COLOR: red"> Mode</SPAN><SPAN style="COLOR: blue">=</SPAN><SPAN style="COLOR: blue">TwoWay</SPAN><SPAN style="COLOR: blue">}</SPAN><SPAN style="COLOR: blue">"</SPAN> <SPAN style="COLOR: red"> PartManager</SPAN><SPAN style="COLOR: blue">="{</SPAN><SPAN style="COLOR: #a31515">Binding</SPAN><SPAN style="COLOR: red"> Path</SPAN><SPAN style="COLOR: blue">=</SPAN><SPAN style="COLOR: blue">PartManager</SPAN><SPAN style="COLOR: blue">}</SPAN><SPAN style="COLOR: blue">"</SPAN> <SPAN style="COLOR: red"> LinkingTool</SPAN><SPAN style="COLOR: blue">="{</SPAN><SPAN style="COLOR: #a31515">Binding</SPAN><SPAN style="COLOR: red"> Path</SPAN><SPAN style="COLOR: blue">=</SPAN><SPAN style="COLOR: blue">LinkingTool</SPAN><SPAN style="COLOR: blue">}</SPAN><SPAN style="COLOR: blue">"</SPAN></PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><SPAN style="COLOR: blue"> .....</SPAN></PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><SPAN style="COLOR: blue">ViewModel:</SPAN></PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><SPAN style="COLOR: blue"></SPAN> </PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><SPAN style="COLOR: blue"><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: #2b91af">WorkflowLinkingTool</SPAN> linkingTool = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">WorkflowLinkingTool</SPAN>();
public WorkflowLinkingTool LinkingTool
{
get
{
return this.linkingTool;
}<SPAN style="COLOR: blue">set</SPAN> { <SPAN style="COLOR: blue">this</SPAN>.linkingTool = <SPAN style="COLOR: blue">value</SPAN>; <SPAN style="COLOR: blue">this</SPAN>.OnPropertyChanged(() => <SPAN style="COLOR: blue">this</SPAN>.LinkingTool); } }</PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "> </PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: ">this doesn't work, but this is MVVM</PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: ">The Condition for MVVM is, that the View doesn't handle any Methods or contains any Properties</PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: ">So you mustn't initialize the WorkflowLinkingTool in the View.</PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><img src="http://www.silverlightblog.net/wp-content/uploads/2011/01/MVVM_Relation.jpg" height="299" width="411" border="0" /></PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "> </PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: ">so I'm looking for a solution, where MVVM doesn't get hurt</PRE></PRE></SPAN></PRE><PRE style="FONT-FAMILY: Consolas; COLOR: black; FONT-SIZE: 13px; white: "><SPAN style="COLOR: blue"></SPAN> </PRE></PRE>
Problem Solved!
this.Diagram.MouseMoveTools Count = 4 [0]: {Roche.InCore.DS.UI.WorkflowComponents.WorkflowLinkingTool} [1]: {Roche.InCore.DS.UI.WorkflowComponents.WorkflowDraggingTool} [2]: {Roche.InCore.DS.UI.WorkflowComponents.WorkflowDragSelectingTool} [3]: {Roche.InCore.DS.UI.WorkflowComponents.WorkflowPanningTool} I did the same initializing process with the three other tools in the MouseMoveTools List so the same thing happens to this tools as with the LinkingTool, they were added at the end of the list :)