adding tooltip to edge

Dec 7, 2011 at 12:26 PM
Edited Dec 7, 2011 at 12:33 PM

How to add tooltip to the edges using binding?

I tried to apply this style but I get an empty tooltip:

<Style TargetType="{x:Type graphsharp:EdgeControl}" >

                <ToolTip x:Key="ToolTipEdgeContent" >
                        <TextBlock Text="{Binding ID}"/>
            <Setter Property="ToolTip" Value="{StaticResource ToolTipEdgeContent}"/>

What could the problem be

Dec 7, 2011 at 12:53 PM

Hello rabak,

I faced the same problem (look at "Problems when I compile GraphSharp.Controls from souce code"). today I use the same xaml cunstruct and it works. It seems to have something to do with not machting .NET versions of the dll's and your app's .net version. I downloaded graphsharp again, recompiled it an since there it worked.


Hope this helps


Dec 7, 2011 at 1:21 PM
Edited Dec 7, 2011 at 1:23 PM


i have GraphSharpDemo tooltip working, and i have the latest version. 

but still same problem :S

The tool tip appears but with no data inside it, and i get no exceptions...

Dec 19, 2011 at 1:38 PM
Edited Dec 19, 2011 at 1:43 PM

here is a code sample, the data that i get in the tooltip is: "Type: " without displaying the bind value i have been trying everything out, can someone help...


       <DataTemplate x:Key="TreeDiagramEdgeTemplate" DataType="{x:Type Graph:PocEdge}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Type: "/>
                <TextBlock Text="{Binding Path=Type, Mode=OneWay}" />

        <Style TargetType="{x:Type graphsharp:EdgeControl}" >

            <Setter Property="ToolTip">
				ContentTemplate="{StaticResource TreeDiagramEdgeTemplate}"/>


and the PocEdge Class:


public class PocEdge : Edge<PocVertex>
        public string Type
            private set;
        public string ID
            private set;

        public PocEdge(string id,string type, PocVertex source, PocVertex target)
            : base(source, target)
            ID = id;
            Type= type;

I want to be able to display the type property in the tooltip




Dec 19, 2011 at 2:02 PM

Found the solution if anyone interested, although its from code behind.


in the loaded event of the Graph:

foreach (var e in graphLayout.Children)
                if (e is EdgeControl)
                    (e as EdgeControl).ToolTip ="Type: " + ((e as EdgeControl).Edge as PocEdge).Type;
Good luck :D

Jan 28, 2013 at 12:15 AM

man you are my savior. It looks like a helpful/useful solution! I have been searching for possible solutions on how to do databinding... I was like... What's wrong with my data binding knowledge... You are a champ! Thanx!

Well, your solution did give me some hint on binding the data on the back of the code, which is an excellent idea!!!

In my case, I create the graph, trying to get the ToolTip working, following Sacha's tutorial. I found his databinding not working on customized edges, displaying IDs only. (I have no idea what the fuck how that works having been reading through the graphsharp source code.)

My problem is, I believe, when the graph is loaded, well, the canvas is loaded. there is no graph there yet. When I create a graph by deserializing a file, loaded event doesn't work anymore here. Hence, I have to update the ToolTip content after the graph is created. Not a very nice approach since there is no data binding here, and I have to remember that every time there is a new edge edited/updated, I have to update's Edgecontrol.ToolTip...

Feb 22, 2013 at 2:56 AM
I was facing the same issue and eventually worked out a solution: I needed to explicitly set the DataContext of the Tooltip.

So I added the following Setter to the Style:
            <Setter Property="ToolTip.DataContext" Value="{Binding RelativeSource={RelativeSource Self},Path=Edge}" />
and things started to work.
Mar 4, 2013 at 6:18 PM
thanks IanOfOz! You're like the wizard of Oz ;-)

indeed things started working when setting the ToolTip.DataContext