Vertex Refresh

Aug 19, 2010 at 10:05 AM


Firstly thankyou for creating such an excellent visualisation package.

I have a quick and likely a simple question:

I have a data template:

  <DataTemplate DataType="{x:Type PoCGraph:PocVertex}">

            <Border Name="vertexPanel"
                    Margin="2" Padding="4" CornerRadius="5, 5, 5, 5"
                    BorderThickness="2" BorderBrush="Black">

                <TextBlock Text="{Binding Path=ID}" TextAlignment="Center" Background="{Binding Path=Colour}"
                           FontSize="{Binding Path=HighlightFontSize}"/>


 i have a custom search routine:

 private void BtnZoomClick(object sender, RoutedEventArgs e) {
            // undo the last highlighting
            foreach (PocVertex vertex in this.GraphToVisualize.Vertices.Where(v => v.HighlightFontSize =="72")) {
                vertex.HighlightFontSize = "12";
            // then do the new one :)
            foreach (PocVertex vertex in this.GraphToVisualize.Vertices.Where(v => v.ID.Contains(this.ZoomContent.Text))) {
                vertex.HighlightFontSize = "72";

            this.graphLayout.InvalidateVisual(); // not sure what to call here...

however the size of the font in the vertexes doesn't change (i have checked that HighlightFontSize is indeed updated)
i would hazard that i am not calling the right refresh method on the graphlayout. 
I have tried using HighlightFontSize as both an integer and a string field. I have also tried using ReLayout but sans success :(
Any help would be much appreciated
Sep 17, 2010 at 1:30 PM

i had a similar problem when updating the vertex background color (from a menu list) after clicking over a vertex.

I derived my vertex class from INotifyPropertyChanged and then add event that is raised when i modify the property (eg, I raise it when i change the background color)..i had this style, with a trigger that's activated when i mouse-click on a node (IsHighlighted is true when mouse button is pressed)

<Style TargetType="{x:Type GraphSharp_Controls:VertexControl}">

            <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted" Value="true">
                <Setter Property="Background"  Value="{Binding Path=(UClib:myVertex.HighlightedBackgroundColor)}"/>


and this data template (i set the color of the selected vertex by calling ClickOnNode)

<DataTemplate DataType="{x:Type UClib:myVertex}">
                    <TextBlock MouseLeftButtonDown="ClickOnNode"
                           Text="{Binding Path=ID, Mode=OneWay, FallbackValue=VertexId}"
                           DockPanel.Dock="Top" HorizontalAlignment="Center"

and this is myVertex class 
namespace UClib
public class myVertex  :  INotifyPropertyChanged

      private String HighlightedBackgroundColor = "LightBlue";
      public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

       protected void NotifyPropertyChanged(String info)
            if (PropertyChanged != null)
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(info));

        public myVertex(string id)
            ID = id;
            IsSelected = false;

       public String HighlightedBackgroundColor
       { get { return highlightedBackColor; } set { if (value != highlightedBackColor) { highlightedBackColor = value; NotifyPropertyChanged("HighlightedBackgroundColor"); } } }
   } }
hope this can help you

Sep 17, 2010 at 1:38 PM

this post can help too (i used this to solve my problem)

Oct 13, 2010 at 3:42 PM


thanks for the link & code sample i have got this working now :-)


Dec 14, 2010 at 5:23 PM

i got this error when change what u said

Error 1 'ResourceDictionary' root element requires a x:Class attribute to support event handlers in the XAML file. Either remove the event handler for the MouseLeftButtonDown event, or add a x:Class attribute to the root element. Line 24 Position 24. H:\University\Evaluation Computing\project\GraphColoring\Graph\Resources\PocGraphDataTemplates.xaml 24 24 GraphColoring