I am using Version 1.1.3.3, GoXam. I have a binding issue that shows up at times when adding a node to the diagram. In the sample below, the RelativeSource binding works on teh initially added node, but does not work on an added node (of the same type and DataTemplate). Below is a small sample that demonstrates the issue. The initial node added binds correctly, press the ‘Add’ button and the added node does not find the relativesource binding. Please advise.
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:go="http://schemas.nwoods.com/GoXam"
xmlns:local="clr-namespace:GoXamBrowser"
Title="MainWindow" Height="350" Width="525">
<Border Name="NodeBorder" BorderBrush="Gray" BorderThickness="2" CornerRadius="3" Background="Aqua"
go:Part.SelectionAdorned="True" go:Part.Resizable="True"
go:Node.FromSpot="AllSides" go:Node.ToSpot="AllSides"
go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}">
<go:LinkShape x:Name="Path" StrokeThickness="2"
Stroke="{Binding Path=Part.IsSelected,
Converter={StaticResource theSelectedBrushConverter}}" />
<Polygon Fill="Black" Points="8 4 0 8 2 4 0 0" go:LinkPanel.Index="-1"
go:LinkPanel.Alignment="1 0.5" go:LinkPanel.Orientation="Along" />
<go:Diagram Grid.Row="1" x:Name="myDiagram"
Padding="10"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
NodeTemplate="{StaticResource FieldTemplate}"
LinkTemplate="{StaticResource ReferenceTemplate}" />
[/code] Code-behind for page: [code]
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Northwoods.GoXam;
using Northwoods.GoXam.Model;
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new MainModel("Sample");
var model = new GraphLinksModel();
model.Modifiable = true; // let the model be modified
model.NodeKeyPath = "Key"; // use the GraphModelNodeData.Key property
this.myDiagram.Model = model;
this.myDiagram.Layout = new Northwoods.GoXam.Layout.LayeredDigraphLayout();
myDiagram.Model.AddNode(new SampleNode("First", "first node"));
myDiagram.CommitTransaction("Init");
}
{
myDiagram.StartTransaction("Add");
myDiagram.Model.AddNode(new SampleNode(txtName.Text, "new node"));
myDiagram.CommitTransaction("Add");
}
}
public class MainModel
{
public MainModel(string label) { SharedLabel = label; }
public string SharedLabel { get; set; }
}
public class SampleNode : GraphLinksModelNodeData
{
public SampleNode(string name, string comment) : base()
{
Name = name;
Comment = comment;
}
public string Name { get; set; }
public string Comment { get; set; }
}
public class SampleLink : GraphLinksModelLinkData
{
}
}
[/code]