Hi,
I need some help to get group and ungroup working.
using System;
using System.Collections.ObjectModel;
using System.Windows;
using Northwoods.GoXam.Model;
namespace GoWpfGrouping
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
CreateData();
}
private void CreateData()
{
// model is a GraphModel using GraphModelNodeData<String> as the node data,
// and the node keys are strings
var model = new GraphModel<GraphModelNodeData<String>, String>();
model.NodeKeyPath = "Key"; // use the GraphModelNodeData.Key property
model.ToNodesPath = "ToKeys"; // this node property gets a list of node keys
model.NodeIsGroupPath = "IsSubGraph"; // node property is true if it’s a group
model.GroupNodePath = "SubGraphKey"; // node property gets container’s name
model.NodesSource = new ObservableCollection<GraphModelNodeData<String>>()
{
new GraphModelNodeData<String>()
{
Key = "Alpha",
ToKeys = new ObservableCollection<String>() {"Beta", "Gamma"}
},
new GraphModelNodeData<String>()
{
Key = "Beta",
ToKeys = new ObservableCollection<String>() {"Beta"}
},
new GraphModelNodeData<String>()
{
Key = "Gamma",
ToKeys = new ObservableCollection<String>() {"Delta"},
SubGraphKey = "Epsilon"
},
new GraphModelNodeData<String>()
{
Key = "Delta",
ToKeys = new ObservableCollection<String>() {"Alpha"},
SubGraphKey = "Epsilon"
},
new GraphModelNodeData<String>()
{
Key = "Epsilon",
IsSubGraph = true
},
};
MyDiagram.Model = model;
}
}
}
and in Xaml:
<Window
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" x:Class="GoWpfGrouping.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Grid>
<go:Diagram x:Name="MyDiagram">
<go:Diagram.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding CommandHandler.GroupCommand, ElementName=MyDiagram}" Header="Group" />
<MenuItem Command="{Binding CommandHandler.UngroupCommand, ElementName=MyDiagram}" Header="Ungroup" />
</ContextMenu>
</go:Diagram.ContextMenu>
</go:Diagram>
</Grid>
</Window>
I read something about PrototypeGroup, but have found no description how to use it.