Click here to Skip to main content
Click here to Skip to main content

WPF Diagram Designer - Part 3

By , 29 Feb 2008
 
WPF FlowChart Designer
  • Part 1 - Features: Drag, resize and rotate items on a canvas
  • Part 2 - Features: Toolbox, drag & drop, rubberband selection

Introduction

There exist different techniques to connect items in a typical diagram designer. One approach is to provide connection elements in a toolbox which the user can drop on the designer canvas and then drag the endpoints to the source and sink items. Another approach is that the items themselves provide connection points from which the user can drag a connection to other items. This second strategy is the one I will explain in this article.

Use Case: How to Connect Items

I'm sure you know how to connect items in a designer application, but still I will illustrate this in some detail to make it easier to identify which class is involved in which activity.

If you move your mouse over a designer item four visual elements of type Connector will appear at each side of the item. This default layout is defined in the ConnectorDecoratorTemplate and is part of the default DesignerItem template. Now move your mouse over one of the connectors and the cursor changes to a cross. WPF Diagram Designer: Connecting items
If you now click the left mouse button and start dragging, the connector will create an adorner of type ConnectorAdorner. This adorner is responsible for drawing the path between the source connector and the current mouse position. While dragging, the adorner continuously does hit-testing against the DesignerCanvas to check if the mouse is over a potential sink connector. WPF Diagram Designer: Connecting items
If you release the mouse button over a Connector element the ConnectorAdorner creates a new Connection instance and adds it to the designer canvas' children. If the mouse button is released elsewhere no Connection instance is created. WPF Diagram Designer: Connecting items
Like the DesignerItem the Connection implements the ISelectable interface. If a Connection instance is selected you will see two rectangles at each end of the connection path. They belong to an adorner of type ConnectionAdorner which automatically shows up when a Connection instance gets selected.
Note: A ConnectorAdorner belongs to a Connector and a ConnectionAdorner belongs to a Connection.
WPF Diagram Designer: Connecting items
Each of the two rectangles represents a Thumb control and they are part of a ConnectionAdorner instance which allows you to modify existing connections. WPF Diagram Designer: Connecting items
E.g. If you drag the sink thumb of the connection to another connector and release it there, you can re-connect the existing connection.
Note: The ConnectorAdorner and the ConnectionAdorner are similar in what they do, but they differ in how they make use of an Adorner class.
WPF Diagram Designer: Connecting items

How is a Connection Glued to an Item?

The default layout of the connectors is defined in the ConnectorDecoratorTemplate, which is part of the DesignerItem's template:

 <ControlTemplate x:Key="ConnectorDecoratorTemplate" TargetType="{x:Type Control}">
   <Grid Margin="-5">
     <s:Connector Orientation="Left" VerticalAlignment="Center"
            HorizontalAlignment="Left"/>
     <s:Connector Orientation="Top" VerticalAlignment="Top"
            HorizontalAlignment="Center"/>
     <s:Connector Orientation="Right" VerticalAlignment="Center"
            HorizontalAlignment="Right"/>
     <s:Connector Orientation="Bottom" VerticalAlignment="Bottom"
            HorizontalAlignment="Center"/>
   </Grid>
 </ControlTemplate>

A Connector class has a Position property which specifies the relative position of the connector's centre point to the designer canvas. Because the Connector class implements the INotifyPropertyChanged interface it can notify clients that a property value has changed. Now when a designer item changes its position or its size the connector's LayoutUpdated event is automatically fired as part of the WPF layout procedure. And this is when the Position property gets updated and itself fires an event to notify clients.

 public class Connector : Control, INotifyPropertyChanged
 {
     private Point position;
     public Point Position
     {
         get { return position; }
         set
         {
             if (position != value)
             {
                 position = value;
                 OnPropertyChanged("Position");
             }
         }
     }

       public Connector()
       {
           // fired when layout changes
           base.LayoutUpdated += new EventHandler(Connector_LayoutUpdated);
       }

       void Connector_LayoutUpdated(object sender, EventArgs e)
       {
           DesignerCanvas designer = GetDesignerCanvas(this);
           if (designer != null)
           {
               //get center position of this Connector relative to the DesignerCanvas
               this.Position = this.TransformToAncestor(designer).Transform
                    (new Point(this.Width / 2, this.Height / 2));
           }
       }

    ...

 }

Now we switch over to the Connection class. The Connection class has a Source and a Sink property, both of type Connector. When the source or sink connector is set we immediately register an event handler that listens to the PropertyChanged event of the connector.

  public class Connection : Control, ISelectable, INotifyPropertyChanged
  {
       private Connector source;
       public Connector Source
       {
           get
           {
               return source;
           }
           set
           {
               if (source != value)
               {
                   if (source != null)
                   {
                       source.PropertyChanged -=
                           new PropertyChangedEventHandler(OnConnectorPositionChanged);
                       source.Connections.Remove(this);
                   }

                   source = value;

                   if (source != null)
                   {
                       source.Connections.Add(this);
                       source.PropertyChanged +=
                           new PropertyChangedEventHandler(OnConnectorPositionChanged);
                   }

                   UpdatePathGeometry();
               }
           }
       }

      void OnConnectorPositionChanged(object sender, PropertyChangedEventArgs e)
      {
          if (e.PropertyName.Equals("Position"))
          {
              UpdatePathGeometry();
          }
      }

     ....

  } 

This snippet shows only the source connector, but the sink connector works analogous. The event handler finally updates the connection path geometry, that's it.

Customize Connectors Layout

The default layout and the number of connectors may not always fit your needs. Take the following example of a triangle shaped Path with a customized DragThumbTemplate (see the previous article on how to customize the DragThumbTemplate).

 <Path IsHitTestVisible="False"
       Fill="Orange"
       Stretch="Fill"
       Data="M 0,10 5,0 10,10 Z">
   <s:DesignerItem.DragThumbTemplate>
      <ControlTemplate>
         <Path Fill="Transparent" Stretch="Fill"
                   Data="M 0,10 5,0 10,10 Z"/>
      </ControlTemplate>
   </s:DesignerItem.DragThumbTemplate>
 </Path>       

WPF Diagram Designer: Custom connectors

The problem here is that the connectors are only visible when the mouse is over the item. If you try to reach the connector on the left or right side you may have some problems. But the solution comes in the form of an attached property named DesignerItem.ConnectorDecoratorTemplate that lets you define custom templates for the connector decorator. The usage is best explained with an example:

 <Path IsHitTestVisible="False"
       Fill="Orange"
       Stretch="Fill"
       Data="M 0,10 5,0 10,10 Z">
   <!-- Custom DragThumb Template -->
   <s:DesignerItem.DragThumbTemplate>
      <ControlTemplate>
         <Path Fill="Transparent" Stretch="Fill"
               Data="M 0,10 5,0 10,10 Z"/>
      </ControlTemplate>
   <s:DesignerItem.DragThumbTemplate>
   <!-- Custom ConnectorDecorator Template -->
   <s:DesignerItem.ConnectorDecoratorTemplate>
       <ControlTemplate>
          <Grid Margin="0">
             <s:Connector Orientation="Top" HorizontalAlignment="Center"
                    VerticalAlignment="Top" />
             <s:Connector Orientation="Bottom"  HorizontalAlignment="Center"
                    VerticalAlignment="Bottom" />
             <UniformGrid Columns="2">
                <s:Connector Grid.Column="0" Orientation="Left" />
                <s:Connector Grid.Column="1" Orientation="Right"/>
             </UniformGrid>
          </Grid>
       </ControlTemplate>
    </s:DesignerItem.ConnectorDecoratorTemplate>
 </Path> 

WPF Diagram Designer: Custom connectors

This solution provides a better result but it still needs some tricky layout, which may not always be feasible. For this I provide a RelativePositionPanel that allows you to position items relative to the bounds of the panel. The following example positions three buttons on a RelativePositionPanel by setting the RelativePosition property, which is an attached property.

 <c:RelativePositionPanel>
    <Button Content="TopLeft" c:RelativePositionPanel.RelativePosition="0,0"/>
    <Button Content="Center" c:RelativePositionPanel.RelativePosition="0.5,0.5"/>
    <Button Content="BottomRight" c:RelativePositionPanel.RelativePosition="1,1"/>
 </ControlTemplate>

This panel can be quite handy when it comes to arrange connectors:

 <Path IsHitTestVisible="False"
       Fill="Orange"
       Stretch="Fill"
       Data="M 9,2 11,7 17,7 12,10 14,15 9,12 4,15 6,10 1,7 7,7 Z">
   <!-- Custom DragThumb Template -->
   <s:DesignerItem.DragThumbTemplate>
      <ControlTemplate>
         <Path Fill="Transparent" Stretch="Fill"
               Data="M 9,2 11,7 17,7 12,10 14,15 9,12 4,15 6,10 1,7 7,7 Z"/>
      </ControlTemplate>
   </s:DesignerItem.DragThumbTemplate>
   <!-- Custom ConnectorDecorator Template -->
   <s:DesignerItem.ConnectorDecoratorTemplate>
       <ControlTemplate>
          <c:RelativePositionPanel Margin="-4">
             <s:Connector Orientation="Top"
                c:RelativePositionPanel.RelativePosition="0.5,0"/>
             <s:Connector Orientation="Left"
                c:RelativePositionPanel.RelativePosition="0,0.385"/>
             <s:Connector Orientation="Right"
                c:RelativePositionPanel.RelativePosition="1,0.385"/>
             <s:Connector Orientation="Bottom"
                c:RelativePositionPanel.RelativePosition="0.185,1"/>
             <s:Connector Orientation="Bottom"
                c:RelativePositionPanel.RelativePosition="0.815,1"/>
          </c:RelativePositionPanel>
       </ControlTemplate>
    </s:DesignerItem.ConnectorDecoratorTemplate>
 </Path>  

WPF Diagram Designer: Custom connectors

Outlook

In the next article I will concentrate on commands:

  • Cut, copy, paste
  • Grouping of items
  • Align items
  • Z-ordering (bring to front, send to back,...)

History

  • 24 February, 2008 -- Original version submitted

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

sukram
Austria Austria
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionOther method of connector creation?memberlshah65522 May '13 - 10:30 
In this article another method of creating a connector was mentioned, specifically the providing of "connection elements in a toolbox which the user can drop on the designer canvas and then drag the endpoints to the source and sink items." Does anyone know how to go about this method, or have any resources they can share? I've been trying to adapt the connector from this article, but I feel like I'm making it harder than it needs to be.
QuestionTo change Existing symbols in the project.memberMayurNavsupe29 Mar '13 - 1:10 
I found your project very helpful. Thank you for that. I am doing a small project same like this one, with some changes to make.
How can I replace the image (circle, rectangle, ellipse ) with my images??
QuestionHow can i create double sided arrow ?membergavri200030 Dec '12 - 6:23 
What should i change in the Connection instance properties ?
 
Thanks in advance
AnswerRe: How can i create double sided arrow ?memberjollycode21 Feb '13 - 3:07 
Go to Connection.cs
Scroll down to line 157 and change line
private ArrowSymbol sourceArrowSymbol = ArrowSymbol.None;
to
private ArrowSymbol sourceArrowSymbol = ArrowSymbol.Arrow;

QuestionRe: How can i create double sided arrow ?membergavri200010 Mar '13 - 13:19 
Thank you jollycode Smile | :)
 
I have one more question (i have more but i don't want to drive you crazy...)
My final studies project is a WPF application that converts an Entity Relationship Diagram into
a database, and i'm using this project to build the ERD on the canvas (i hope this is fine with the creator). The question is:
 
Is there any way to find out which DesignerItem was clicked on the canvas ? (if it's a rectangle this means it's EntitySet etc.) My next step is to open properties menu when an entity or relation was clicked.
 
Thanks again Smile | :)
AnswerRe: How can i create double sided arrow ?memberjollycode10 Mar '13 - 14:09 
You're most welcome!
You can use SelectionService to do that. You can look at the examples how in the DesignerCanvas.Commands.cs file. It goes something like this:
 
var selectedItems = from item in SelectionService.CurrentSelection.OfType<DesignerItem>()
                                select item;
 
or in case of a Connection use:
 
var selectedItems = from item in SelectionService.CurrentSelection.OfType<Connection>()
                                select 
 
You can then add a "Properties" manu item inside the Connection.xaml and DesignerItem.xaml, also create a command that will display a dialog box with all the properties of that Connection/DesignerItem.
 
Also I would suggest you take a look at MVVM Diagram Designer that was inspired by this tutorial.
 
I hope this helped. Wink | ;)
Questionhow to get points of shape?memberhamidehkarimi2 Oct '12 - 2:04 
if i design a star how can get data for this?
QuestionHow to draw lines direct from Connector ?memberJavidan720 Jun '12 - 23:46 
Hi. At 1st , thanks for this amazing project. I really need it. My problem for now is that i want to draw lines direct from Connector, not from DesignerItem. I achieved this with replacing startPoint and endPoint parameters with the Connector.Position at GetConnectionLine (PathFinder) methods. But when i want to draw line to outside of DesignerItem it gives exception at GetOrientation methods. What to do ?
Questionwhat if we add rulesmemberrdeschain15 May '12 - 5:41 
hi,first of all I wanna say that your diagram saved my life I made some changes like adding a zoombox and adding other shapes for uml diagrams.I'm about to finish my thesis but had a difficulty.I have to implement some rules:
1-for instance an A shape have to be derived from an A and B from B.
2-how can I use diamond or arrow shape by my own will,I mean I may want composition relation or a normal arrow shaped relation.But the rule is I have to have the control.I saw you added a diamond in xaml and I used it but ı cant do the both if I want.

I'm in a rush nowadays,please help me
thaks a lot!
QuestionVery coolmemberCIDev25 Apr '12 - 11:24 
Cool stuff on Connectors. Cool | :cool:
Just because the code works, it doesn't mean that it is good code.

QuestionSilverlightmemberAte9 Feb '12 - 2:40 
Hello i realy like the article how can i port it to silverlight?
GeneralMy vote of 5memberShrishailHalijol11 Jan '12 - 19:53 
Wonderful implementation...
Questionnew image errormembershelby6720 Nov '11 - 18:50 
I opened up the project, went to the images folder and placed some new ones in there then went to the SymbolStencils.xaml to edit the new paths for the images. It failed to display when I ran it, any idea why????
GeneralMy vote of 5memberemmeric16 Nov '11 - 12:48 
Impressive capabilities of WPF and great knowledge of the author
QuestionHow to add Text to Designer Item in your article [modified]memberaloktambi14 Sep '11 - 2:06 
Hi,
Your article is very useful for our req. Can you tell me , how we can add text to Designer Item in Canvas
 

Alok Khandelwal
alok.khandelwal2@honeywell.com

modified on Wednesday, September 14, 2011 8:37 AM

GeneralWPF LIST Viewmembersaurabhd1314 Jul '11 - 10:47 
Hi Sukram
 
First of all i thank you for your wonderful article on adornes.
I have some doubts about thumb control. to explain the entire scenario i have to post my code to you but before that just want to make sure that you still take questions.
 
Please can you let me know if you still reply to the messages posted.
 
And thanks again for the artical.
 
Regards
Saurabh
GeneralMy vote of 5membersalim4187 Jul '11 - 1:39 
how can i thank u?
GeneralToolBox and ToolBoxItem do not work as expected while using DataTemplatememberBharat Mane13 Jun '11 - 1:48 
Hi Sukram,
I am using this source code as a base for one of my current project, and i am really loving it.
 
While building on it, I was trying to convert the Stencil, from repeated code to a simple DataTemplate so that i can save the image path into some XML for all the objects and can just bind the data to ToolBox ItemSource and provide the DataTemplate. But I spent whole day today and couldn't get any luck on it.
 
The below portion works fine
<s:Toolbox x:Name="myToolBox" x:Key="UIElementStencil" SnapsToDevicePixels="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ItemsControl.Items>
<s:ToolboxItem Title="Title" >
<Viewbox Stretch="Uniform" IsHitTestVisible="False">
Some Content
</Viewbox>
</s:ToolboxItem>
<s:ToolboxItem Title="Title" >
<Viewbox Stretch="Uniform" IsHitTestVisible="False">
<svgSharp:SvgCanvas Style="{StaticResource Fan}" ToolTip="Sample Shape">
Some Content
</svgSharp:SvgCanvas>
</Viewbox>
</s:ToolboxItem>
</ItemsControl.Items>
</s:Toolbox>
 
But the same one if i put it in DataTemplate
<s:Toolbox x:Name="myToolBox" ItemsSource="{Binding Path=MyItems}" x:Key="UIElementStencil" SnapsToDevicePixels="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ItemsControl.ItemTemplate>
<DataTemplate>
<s:ToolboxItem Title="Title" >
<Viewbox Stretch="Uniform" IsHitTestVisible="False">
Some Content using data binding
</Viewbox>
</s:ToolboxItem>
</DataTemplate>
</ItemsControl.ItemTemplate>
</s:Toolbox>
 
In this case the everything get rendered except the toolboxitem's content. I used the WPF inspector to inspect the data and in the data, below rectangle appears from the toolboxitem style,
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
Trigger also works
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
 
However, the below portion comes empty
<ContentPresenter Content="{TemplateBinding bb}"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
 

It will be really gr8 if you could provide some pointer on this.
 
Thanks in advance
Bharat Mane
GeneralLooks good!memberxzz019529 Oct '10 - 5:57 
I will have to download and experiment later....Thanks!
GeneralExtracting information from controlmembermisiek76721 Jul '10 - 12:24 
Hi
Let's say that I drag and drop couple of TextBoxes to DesignerCanvas. How can I retrieve standard information from this Control
e.g Name, Height, Width, Text etc?
Thanks in advance
GeneralWant to connect with some specific Rulesmemberanilmomin875 Jul '10 - 0:49 
Hi i m a new to WPF,It is an excellent example, I want to extent this example. I want to connect the flowchart objects with some specific rules applied, For example the diagram should always start with start symbol and no other symbol should be allowed to to connect to start symbol. Hope will find quick response...
 
regards Anil Momin
GeneralAdding TextmemberMember 228021615 May '10 - 0:35 
How you add text within those shapes.. like process
Thanks
Generalsmall spacing between an item and a Connectormembersantosh56127 Apr '10 - 6:00 
I Have a Question regarding the small spacing between an item and a Connector...
I posted at one of the microsoft forums, please refer to :
 
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3568e661-76cc-469d-91f4-761763838d99
 
Please help me in this,
 

 
Thanks,
 

 
San
GeneralRe: small spacing between an item and a ConnectormemberMitch Belew27 Mar '12 - 7:03 
any luck on closing the space between the connector and the item?
QuestionHow to change connector thicknessmemberswati banerjee8 Apr '10 - 17:43 
I need to change the connector thickness.I'm unable to get the property StrokeThickness of PART_ConnectionPath at runtime.
 
Thanx and Regards
Swati
hi

GeneralYou are the bombmemberlayinka18 Mar '10 - 2:32 
Wow!thanks a lot, i have been trying to do sometin liek this, but i just kept on getting stuck, thanks for sharing,kip up d cool work
QuestionHow to react on a doubleclick of DesignerItem in DesignerCanvas?memberLalaa26 Jan '10 - 8:18 
Hi all,
 
I'd like to get the event doubleclick of all DesignerItems in the DesignerCanvas. How would I have to do this?
 
Id' like to have something like
 
DesignerCanvas Focusable="true" x:Name="MyDesigner" c:DesignerItem.MouseDoubleClick="MyMethodToExecute" Background="{StaticResource WindowBackgroundBrush}"
Margin="10" FocusVisualStyle="{x:Null}"
ContextMenu="{StaticResource DesignerCanvasContextMenu}"
 

Thanks in advance
GeneralDesignerCanvas in AvalonDock.DocumentPane: connection not visiblememberpbisiac24 Nov '09 - 21:50 
hello, I am trying to use AvalonDock together with your code, cause I need to handle more than one DesignerCanvas. When I put my DesignerCanvas into an AvalonDock.DocumentPane everything works (Connectors, connectionadorners) exept for connections, which don't show up (although they are created and regularly "connected"). I tried almost everything but I cant' get connetion drawed.
The AvalonDock.DocumentPane source URL code is http://avalondock.codeplex.com/SourceControl/changeset/view/45809#459018
Any help would be greatly appreciated !
QuestionMultiple Drop Option ?memberamitmmehta12 Nov '09 - 13:34 
you rockThumbs Up | :thumbsup:
 
Thanks for the article , it's really helpful, I am using most of the code from 3 part series
and need your help on an additional feature that i am trying to incorporate .
 
want to know if i can allow multiple items to be Dropped on the canvas .
 
I noticed that the ToolBox is a ItemsControl and all the ToolBoxItem are ContentControl,
to make multiple drop work these are the steps i tried
1. Changed ToolBox from ItemsControl to ListBox
2. Added SelectionMode to Multiple ( in the Styles )
3. Changed ToolBoxItem from ContentControl to ListBoxItem
4. Added Code to keep a List of items Selected OnPreviewMouseDown of toolBoxItem
5. Updated Code 2 call DoDrop for each Item in the List from Step 4 .
6. Still Does Not work Confused | :confused:
 
Can you please suggest me how to go about this .
 

Thanks in Advance
- Amit
GeneralView in Web PagememberMember 290319911 Nov '09 - 13:15 
Hi, first thanks for this great application, only one question, its posibble to view the diagram in a webform, can you give a hand with this???
 
Thank's again
GeneralSpline Shaped ConnectorsmemberBug Me Not5 Nov '09 - 20:17 
Does anyone have any idea how to do curved / spline connectors instead of the straight line / right angle connectors?
QuestionConnections by CodememberCASEDW6 Oct '09 - 19:22 
Excellent series, could you please help me creating connections by code. I've already created DesignerItems with text inside by code, but i don't know how to add connections yet, sorry about my english i'm from Colombia. Thank You
AnswerRe: Connections by CodememberErik Haselsteiner9 Nov '09 - 4:57 
I tried it with the following code:
            var startConnector = new Connector
                                     {
                                         Position = startPoint,
                                         ParentDesignerItem = startItem,
                                         Orientation = startOrientation
                                     };
            var sinkConnector = new Connector
                                    {
                                        Position = sinkPoint,
                                        ParentDesignerItem = sinkItem,
                                        Orientation = sinkoOrientation
                                    };
            var sinkAdorner = new ConnectorAdorner(cvDesktop, sinkConnector);
            var connection = new Connection(startConnector, sinkConnector);
 
            canvasDesktop.Children.Insert(0, connection);
 
With this code the connections will be visible but they are not really connected to the DesignerItem and I do not know why at the moment. Can anyone help us out?
Thanks!
GeneralRe: Connections by Codemembermikesz8421 Dec '09 - 23:07 
What you really need is to determine which Connectors are at your block, nto to create new ones.
 
Add this code to DesignerItem -
 

public Connector ConnectorRight
{
get
{
Control connectorDecorator = this.Template.FindName("PART_ConnectorDecorator", this) as Control;
connectorDecorator.ApplyTemplate();
return connectorDecorator.Template.FindName("Right", connectorDecorator) as Connector;
}
}

and do the same for Bottom, Left and Top (with minor changes).
 
Then you can create connection of two items like this (example in Window1.xaml.cs), it and it2 are already existing DesignerItems drawed at canvas -
 

ConnectorAdorner sinkAdorner = new ConnectorAdorner(this.UIcanvasDesigner, it2.ConnectorLeft);
Connection connection = new Connection(it.ConnectorRight, it2.ConnectorLeft);
 
this.UIcanvasDesigner.Children.Add(connection);

 
Hope it helps.
GeneralFlow documentmemberkrishanth272 Oct '09 - 22:54 
Hai
is this possible to have this diagram designing functionality in a flow document?That means when i create a flow document i should be able to drag and drop and draw in that document like done in this project?
 
Thanks
Kaja
QuestionAbout the problem of connector linesmembery-tnka10 Sep '09 - 1:54 
This article was consulted very much.
 
By the way, connection of between very small Shape and very large Shape will draw a strange line. It seems that surplus Point is added by the OptimizeLinePoints method when I investigate this sample code.
Questionhow to add an image to connectormemberxird26 Jul '09 - 2:49 
hi,
 
im wondering if its possible to add an image to PathGeometry?
since pathgeometry is currently bind on PART_ConnectionPath.
Thank you
QuestionCan I integrate it with Silverlight 3?memberKunalChowdhury19 Jul '09 - 21:14 
Is it possible to integrate the same with Silverlight 3? I tried it but got lots of error. Any help?
 
Regards,
- Kunal Chowdhury (My Blog)
 

GeneralSaving Object Positions to a filememberrougeagle2 Jun '09 - 13:58 
Have you considered trying to save object positions to a file? I believe it would be pretty neat to be able to do that. I have been looking for a way to make WPF user interfaces easy to create, and I believe your diagramming app would be a great start. Do you have any ideas about how to save the positions of each object so that if a program opened up that file, it could reproduce the locations, sizes, rotations, etc of all components on the canvas? If there is a way to get an application to spit out XAML for reproducing the contents of the canvas that would be pretty neat too. Any insight you could provide would be greatly appreciated.
GeneralWow!memberstano3 Apr '09 - 16:43 
Great example. Got my 5.
Generaldifferent 'DesignerItems'memberMember 3418148 Mar '09 - 5:00 
Hi all!
 
I love your articles about the WPF Diagram Designer ! Now i've a question (i'm new to WPF):
 
Is it possible to have different DesignerItems? I wanna have a virtual method Execute in the DesignerItem class. Then i derive from this DesignerItem and only implement the Execute function (e.g. different execution modes per Derived designerItem).
 
Now my problem is, to generate the different derived DesignerItems. When i drag a item to the canvas -> the derived DesignerItem should be used and e.g. when i klick to the DesignerItem the Execute of the underlaying DesignerItem should be executed!
 
Does anybody know what i mean and need?
 
thx a lot Wink | ;)
GeneralRe: different 'DesignerItems'memberWolfMoon18 Mar '09 - 6:08 
Look carefully into solution code. You will find there ToolboxItem class. All you have to do is to change OnMouseMove method there, and corresponding OnDrop method on DesignerCanvas class. In first method you put your class in dragged item data, OnDrop you check, if dragged item is your type (e.g. nobody is trying to drop file on your application window), restore it from DragDrop item, and handle it any way you want. I used this approach to create data base migration schemas based on this solution - user drags table from list of all database tables and application creates my custom control on DesignerCanvas to handle this table (e.g. show migration table options, list columns etc.)
QuestionHow can I delete your object from canvasmemberChanachon Pruchayahmaytha23 Feb '09 - 18:06 
Please help me . I cannot delete DesingerItem from Canvas... Cry | :((
QuestionCreating different ports for different usercontrolmemberthakursaket27 Jan '09 - 0:05 
Hi,
I have 2-3 user control made up of borders and grids and now I want to have 10 ports on user control 12 on another and so on but I am not being able to do so. I have written the code but when I run the code it does'n show any ports except those 4 prots which are defined in designeritem.xaml.
Thanks in advance for the solution.
Generalfor Framework 2.0memberNeo63566110 Jan '09 - 12:26 
Wink | ;) Hi,
 
That is a very nice work, I need it but for FrameWork 2.0,
How can I get it?
 
Thanks
GeneralRe: for Framework 2.0memberWolfMoon18 Mar '09 - 6:09 
It will not work under .NET2.0 This project requires WPF - technology not available before .NET 3.0 and I guess, there is no way to walk it around.
GeneralMake it a free source projectmembersimon.cropp1 Jan '09 - 17:16 
Any change of making this a free source project?
For example
-codeplex
-google code
-source forge
 
All these site make it much easier to deliver your code to people and get feedback on it.
 
Regards
 
Simon
QuestionTwo connections overlapping...how to separe ?memberpbisiac27 Dec '08 - 6:20 
Hello and MANY compliment for this enlighting work. I am developing a little graphical editor based on your sample.
Now I have two objects with two connector each and I draw two connections between them. the connections overlap each other so it's not easy to understand the drawing. I wish to grab a segment of a connection and to be able to displace it frome the other one. Could you help me solving this problem, or give me some hints ?
Alternatively I could modify PathFinder so if the path found overlaps another connection, it offset the segment....
Thank you a lot
Paolo
AnswerRe: Two connections overlapping...how to separe ?memberMitch Belew27 Mar '12 - 7:05 
did you have any luck on getting the a wire crossing another to at least do a visual crossover?
General[Message Removed]memberKatekortez25 Oct '08 - 9:07 
Spam message removed

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 29 Feb 2008
Article Copyright 2008 by sukram
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid