I am trying to use the Palette control, but I am not successful…
Below is my XAML and Code-behind.
<FrameworkElement.Resources>
<go:DataTemplateDictionary x:Key=“TemplateDictionary”>
<go:NodePanel
Width=“20” Height=“20”
Sizing=“Fixed”
go:Part.LayerName=“Foreground”
go:Part.SelectionElementName=“Ellipse”
go:Part.SelectionAdorned=“True”
go:Part.Resizable=“False”
go:Node.LocationSpot=“Center”
go:Node.Avoidable=“False” go:Node.LinkableFrom=“True” go:Node.LinkableTo=“True”
go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}">
</go:NodePanel>
</go:DataTemplateDictionary>
</FrameworkElement.Resources>
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<go:Palette
x:Name=“palette” MaximumSelectionCount=“1”
NodeTemplateDictionary="{StaticResource TemplateDictionary}"
Grid.Row=“0” Background=“LightBlue”>
go:Palette.Layout
<go:GridLayout Alignment=“Position” CellSize=“5 5”></go:GridLayout>
</go:Palette.Layout>
</go:Palette>
<go:Diagram
x:Name=“myDiagram”
NodeTemplateDictionary="{StaticResource TemplateDictionary}"
Grid.Row=“1” Background=“Azure” AllowDrop=“True”>
</go:Diagram>
Code behind - approach 1
var palettemodel = new MyModel();
palettemodel.NodesSource = new List()
{
new ProcessData() { Key=“P”, Text=“Process Unit” },
new ValveData() { Key=“V”, Text=“Valve”},
};
palette.Model = palettemodel;
With this approach, I am able to assign the nodes the the node template, but I am not allowed to drag the node to the diagram.
Code behind - approach 2
List nodesSource = new List()
{
new ProcessData() { Key=“P”, Text=“Process Unit” },
new ValveData() { Key=“V”, Text=“Valve”},
};
palette.NodesSource = nodesSource;
With this approach, I am able to drag the node to the diagram, but the node template is not assigned…