Updating link label text not displayed properly

I am trying to update the link label text programatically. But it is not displayed properly when the new link text is bigger than old text.

This is initial link text where link text = "test"
It shows following incorrect text when I programatically update the link text. (link text="Updated Link Text")
I expect it should display as below. (It corrects isself when I click on link)
I think that the textbloxk which hold the text is not getting resized when we provide new text for it. Is there any way I can force it to update itself and displays the new label text properly?
Could you please check my code if I am doing any mistake?

<UserControl x:Class="LinkTextIssue.MainPage"<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" />









d:DesignHeight="300" d:DesignWidth="400">


<DataTemplate x:Key="NodeTemplate">

<StackPanel Orientation="Vertical" go:Part.SelectionAdorned="True" go:Part.Deletable="False"

go:Node.IsTreeExpanded="True" >

<go:NodePanel Sizing="Auto"




<Path go:NodePanel.Figure="Rectangle" Fill="LightGray" />


<TextBlock Text="{Binding Path=Data.Name}"

MinWidth="100" MaxWidth="100" TextWrapping="Wrap"

HorizontalAlignment="Left" />





<DataTemplate x:Key="LinkTemplate">

<go:LinkPanel go:Part.SelectionElementName="Path" go:Part.SelectionAdorned="True" >


<go:Route RelinkableFrom="False" RelinkableTo="False" />


<Path go:LinkPanel.IsLinkShape="True" Stroke="Black"

x:Name="Path" StrokeThickness="1" />

<Polyline Stroke="Black" StrokeThickness="1"

Points="0 0 8 4 0 8" go:LinkPanel.Alignment="1 0.5"

go:LinkPanel.Index="-1" go:LinkPanel.Orientation="Upright" />

<TextBlock Text="{Binding Path=Data.LabelText, Mode=TwoWay}" go:LinkPanel.Offset="8 8"

FontSize="9" go:Part.TextEditable="False" go:LinkPanel.Orientation="Along" />




<Grid x:Name="LayoutRoot" Background="White">


<RowDefinition Height="35"/>

<RowDefinition Height="*"/>


<StackPanel Orientation="Horizontal" Grid.Row="0">

<Button Content="Reset" x:Name="btnReset" Click="btnReset_Click"></Button>

<Button Content="Change Link Text" x:Name="btnChangeLinkText" Click="btnChangeLinkText_Click"></Button>


<go:Diagram x:Name="graph1" Grid.Row="1"




NodeTemplate="{StaticResource NodeTemplate}"

LinkTemplate="{StaticResource LinkTemplate}">


<golayout:LayeredDigraphLayout LayerSpacing="150" x:Name="graphLayout" >







using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

using Northwoods.GoXam.Model;

using System.ComponentModel;

namespace LinkTextIssue


public partial class MainPage : UserControl


MyLink link;

public MainPage()





private void Init()


var model = new GraphLinksModel<MyNode, String, String, MyLink>();

model.Modifiable = true;

model.NodeKeyPath = "Name";

MyNode node1 = new MyNode("node1");

MyNode node2 = new MyNode("node2");



link = model.AddLink(node1, "", node2, "");

link.LabelText = "test";

graph1.Model = model;


private void btnReset_Click(object sender, RoutedEventArgs e)


graph1.LinksSource = null;

graph1.NodesSource = null;



private void btnChangeLinkText_Click(object sender, RoutedEventArgs e)


if (link != null)


link.LabelText = "Updated Link Text";




public class MyNode : GraphLinksModelNodeData<String>


public string Name { get; set; }

public MyNode(string name)


Name = name;

Key = name;



public class MyLink : GraphLinksModelLinkData<String, String>


String labelText;

public String LabelText




return labelText;




string oldVal = labelText;

labelText = value;

RaisePropertyChanged("LabelText", oldVal, value);





Whenever one changes a model or any model data, one must do so inside a transaction.

Hi Walter,

I tried using transaction but it is not redrawing the link text.
Is is correct?

private void btnChangeLinkText_Click(object sender, RoutedEventArgs e)<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" />


var model = graph1.Model;


if (link != null)


link.LabelText = "Updated Link Text";





Yes, that’s better.
(Although I should point out an unrelated problem, in that your “LabelText” property setter is calling RaisePropertyChanged unconditionally, instead of checking first that the value really did change.)

I would need to investigate further why the link label isn’t updating properly.
For now perhaps the following will work inside your transaction:
graph1.PartManager.FindLinkForData(link, model).Remeasure();

Hi Walter,

Your suggestion of using Remeasure() has solved my problem.
I will also implement your other suggestion about conditionally using RaisePropertyChanged.
Thanks a lot,

Hi Walter,
I’ve run into the same problem that the label of the link is not updated.
In my case it’s not really change to the diagram model because we simply allow the user to change data that is related to the diagram, but it’s not the diagram itself. Specifically we display a process and each link represent single activity. When the user change the type of the activity we would like to reflect the updated activity type in the diagram, but it’s not change to the diagram like different from or to nodes.

I’ve used your Remeasure workaround - I hope it will not cause performance problem or other side effects - currently it look like it working great.