This project is read-only.

Tag or Tooltip on Edges

Dec 17, 2012 at 1:31 PM

Dears, i have developed a solution using Graph sharp.

But i failed to set tags or tool-tips.  

Could anyone suggest a complete solution ?

i have tried many solutions across data templates, Triggers , blah blah.

Thanks and your help is highly appreciated.

For sending demos : mzaatar@acm.org

Dec 17, 2012 at 1:51 PM

Modify the ControlTemplate of the EdgeControl. You can find the default ControlTemplate here:

http://graphsharp.codeplex.com/SourceControl/changeset/view/9c108fe2dfa4#Source/Graph#.Controls/Themes/Generic.xaml

Dec 17, 2012 at 2:52 PM

For me, having a ToolTip Setter in the style for the EdgeControl (and/or VertexControl) has worked nicely. For example (my custom edges have a 'Description' property to which I am binding the tool-tip content):

 

      <Style TargetType="{x:Type graphsharp:EdgeControl}">
            <Style.Resources>
                <ToolTip x:Key="ToolTipContent">
                    <StackPanel>
                        <TextBlock FontWeight="Bold" Text="Description"/>
                        <TextBlock Text="{Binding Description}"/>
                    </StackPanel>
                </ToolTip>
            </Style.Resources>
            <Setter Property="ToolTip" Value="{StaticResource ToolTipContent}"/>
            .......
     </Style>

 

The only problem I have is that I can't seem to make the tool-tip show for longer than 5 seconds. I've tried adding StaysOpen="True" to the ToolTip, as well as the following on the EdgeControl style

 

<Setter Property="ToolTipService.ShowDuration" Value="10000"/>

but both don't seem to work. It's nothing crucial but I do find it annoying, anyone have a solution?

 

Dec 17, 2012 at 9:59 PM
regulus26 wrote:

For me, having a ToolTip Setter in the style for the EdgeControl (and/or VertexControl) has worked nicely. For example (my custom edges have a 'Description' property to which I am binding the tool-tip content):

 

      <Style TargetType="{x:Type graphsharp:EdgeControl}">
            <Style.Resources>
                <ToolTip x:Key="ToolTipContent">
                    <StackPanel>
                        <TextBlock FontWeight="Bold" Text="Description"/>
                        <TextBlock Text="{Binding Description}"/>
                    </StackPanel>
                </ToolTip>
            </Style.Resources>
            <Setter Property="ToolTip" Value="{StaticResource ToolTipContent}"/>
            .......
     </Style>

 

The only problem I have is that I can't seem to make the tool-tip show for longer than 5 seconds. I've tried adding StaysOpen="True" to the ToolTip, as well as the following on the EdgeControl style

 

<Setter Property="ToolTipService.ShowDuration" Value="10000"/>

but both don't seem to work. It's nothing crucial but I do find it annoying, anyone have a solution?

 

It works only when it is in separated solution, when i add the Xaml as User Control or as Window in another application, IT DOESNOT WORK !!!

It tries to find the "Description" (for example) in the view model !!! If i'm right, it searches in different DataContext.

 

any Solution ?

Dec 17, 2012 at 11:12 PM

Dears,

Finally The tag appeared :) Thanks to http://graphsharp.codeplex.com/discussions/72119

But the solution needs to be more descriptive, i worked hard to get it working.

If anyone need help, mail me : mzaatar@acm.org

Dec 18, 2012 at 12:45 AM

I think if you familiar with WPF and it's templating the solution is pretty straightforward. If you're not familiar with WPF it's not the Graph# project's problem...

Dec 24, 2012 at 1:02 PM
regulus26 wrote:

For me, having a ToolTip Setter in the style for the EdgeControl (and/or VertexControl) has worked nicely. For example (my custom edges have a 'Description' property to which I am binding the tool-tip content):

 

      <Style TargetType="{x:Type graphsharp:EdgeControl}">
            <Style.Resources>
                <ToolTip x:Key="ToolTipContent">
                    <StackPanel>
                        <TextBlock FontWeight="Bold" Text="Description"/>
                        <TextBlock Text="{Binding Description}"/>
                    </StackPanel>
                </ToolTip>
            </Style.Resources>
            <Setter Property="ToolTip" Value="{StaticResource ToolTipContent}"/>
            .......
     </Style>

I'm using the same code in my project. I copied my project from the tutorial:
http://sachabarbs.wordpress.com/2010/08/31/pretty-cool-graphs-in-wpf/

I've only translated the project in vb and changed some names. Now I've done other changes, but the tooltip never worked after the translation. I can't understand why... This should be a problem with WPF, not related with G#. But maybe someone can help me!!!