This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
To illustrate my dilemma easier, I drawn a picture for your reference, please see attached picture. As you can see, the final outcome is to produce 3 types of different nodes, that based on the same NodeStyle, but with different ConnectionPointThumb template. The easiest way ofcourse is to make each node using different NodeStyles and set the "ItemTemplate" of the ItemsControl in each style to different template accordingly. But my intention is to minimize the redundancy, and reuse the styles, That is why I reuse the DefaultNodeStyle, since most of the structures of the nodes are the same, just the template (shape & colors) are different. So, the question comes in: How can I switch between different ConnectionPointThumb template for different nodes. (Assuming every nodes, they have common ConnectionPoint type, which is for eg: InboundLeft, OutboundRight, AnyboundBottom. |
|
|
Hello I believe the easiest way to do this is to use a connection point template selector. Take a look at the ConnectionPointValidation.FlowDiagrams demo, it has an example of using a connection point template selector. You could create a class that implements the IDataTemplateMatcher. Look at the the ConnectionPointTemplateMatcher in the demo I mentioned for an example. Your custom IDataTemplateMatcher would get the IDiagramConnectionPoint in the Matches method, and then look at it's Connectable property to get the node that it's attached to. That will allow the selector to select a different connection point template based on the node it's attached to. Look at MainWindow.xaml around line 63 to see how these IDataTemplateMatchers are used. Then set the ConnectionPointTemplateSelector of the DiagramFormatter. If I remember correctly, you used to work with version 1 of WPF Diagrams. So it's possible you are using a custom style for the ConnectionPointThumb controls. If so, take a look at the style at line 172 of Generic.xaml to see the 2.0 version of the ConnectionPointThumb style. The ConnectionPointTemplateSelector will only work because of the ContentPresenter at line 177. If you are using a custom style for this thumb control, make sure your style includes a content presenter that sets the ContentTemplateSelector property seen in Generic.xaml. Let me know if you run into any trouble. -Jason |
|