Org Chart

Let me start by saying that I am new to GoXam controls.
I am working on silverlight app and have to build a OrgChart when I came across your control and it was awesome. So I am evaluating before I can ask the company to buy it. Things see relatively simple, but I got stuck.
This is almost what I want, but when I drag the node to reassign parentNode it doesn't work as expected. What am I doing wrong? Also if that works can I intercept that event, because there are some validation that I need to take care of before it is reassigned? I would really appriciate it, if you could give me any help. I am sending the xaml,.cs and object , just to verify ..Let me know what am I doing wrong or it could be a silverlight thing that I am not aware off..
/******************xaml file****************************/
<go:BooleanBrushConverter x:Key="theBooleanBrushConverter"
FalseBrush="White" TrueBrush="Red" /> <DataTemplate x:Key="NodeTemplate"> <Border BorderThickness="1" BorderBrush="Black" Padding="2,0,2,0" CornerRadius="3" Background="{Binding Path=Part.IsDropOntoAccepted, Converter={StaticResource theBooleanBrushConverter}}" go:Part.DropOntoBehavior="AddsLinkFromNode" go:Node.SelectionAdorned="True" go:Part.Selectable="True" go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"> <StackPanel go:Node.LinkableFrom="False" go:Node.LinkableTo="False" Cursor="Arrow"> <TextBlock Text="{Binding Path=Data.Name, Mode=TwoWay}" FontWeight="Bold" go:Part.TextEditable="True" MinWidth="10" MinHeight="15" /> <StackPanel Orientation="Horizontal"> <TextBlock Text="Name: " /> <TextBlock Text="{Binding Path=Data.NodeType, Mode=TwoWay}" go:Part.TextEditable="True" MinWidth="10" /> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock Text="ID: " /> <TextBlock Text="{Binding Path=Data.NodeID}" /> <TextBlock Text=" Parent: " /> <TextBlock Text="{Binding Path=Data.ParentID}" /> </StackPanel> <TextBlock Text="{Binding Path=Data.Comments, Mode=TwoWay}" TextWrapping="Wrap" MaxWidth="200" MinWidth="10" MinHeight="15" go:Part.TextEditable="True" go:Part.TextAspectRatio="2"/> </StackPanel> </Border> </DataTemplate> <DataTemplate x:Key="LinkTemplate"> <Path go:LinkPanel.IsLinkShape="True" Stroke="Black" StrokeThickness="1" go:Link.SelectionAdorned="True"> <go:Link.Route> <go:Route Routing="Orthogonal" Corner="3" RelinkableFrom="True" RelinkableTo="True" /> </go:Link.Route> </Path> </DataTemplate> </UserControl.Resources> <Grid>

<StackPanel x:Name=“VPanel” Orientation=“Vertical” Background=“Bisque”>
<my:DataGrid x:Name=“dbGrid” Width=“300”>

<StackPanel x:Name=“OperationPanel” Orientation=“Horizontal” HorizontalAlignment=“Left” VerticalAlignment=“Top”>
<Button x:Name=“Add” Height=“25” Width=“30” Content=“Add” Margin=“3,3,3,3” Click=“Add_Node” />
<Button x:Name=“Delete” Height=“25” Width=“30” Content=“Del” Margin=“3,3,3,3” Click=“Del_Node” />
<go:Diagram x:Name=“myDiagram”
HorizontalContentAlignment=“Center” VerticalContentAlignment=“Center”
NodeTemplate="{StaticResource NodeTemplate}" LinkTemplate="{StaticResource LinkTemplate}" Margin=“72,74,94,0”>

<golayout:TreeLayout ConditionFlags=“Standard NodeSizeChanged”
TreeStyle=“LastParents” Arrangement=“Horizontal”
Angle=“90” Alignment=“CenterSubtrees” LayerSpacing=“35”
AlternateAngle=“0” AlternateAlignment=“Start”
AlternateNodeIndent=“10” AlternateNodeIndentPastParent=“1.0”
AlternateLayerSpacing=“30” AlternateLayerSpacingParentOverlap=“1.0”
AlternatePortSpot=“0 1 20 0” AlternateChildPortSpot=“MiddleLeft” />
<gotool:DraggingTool DropOntoEnabled=“True” />

/********************.cs file********************/
public partial class MainPage : UserControl { ObservableCollection<SHierarchyNode> _result = null; public MainPage() { InitializeComponent(); DataServiceASMX.DataWebServSoapClient proxyASMX = new DataWebServSoapClient(); proxyASMX.ListAllNodesCompleted += new EventHandler<ListAllNodesCompletedEventArgs>(proxyASMX_ListAllNodesCompleted); proxyASMX.ListAllNodesAsync();

void proxyASMX_ListAllNodesCompleted(object sender, ListAllNodesCompletedEventArgs e)
ObservableCollection<HierarchyNode> _allNodes = new ObservableCollection<HierarchyNode>();
_allNodes = e.Result;
_result=new ObservableCollection<SHierarchyNode>();
foreach (HierarchyNode node in _allNodes)
_result.Add(new SHierarchyNode() {NodeID=node.NodeID,
TreeModel<SHierarchyNode, int> model = new TreeModel<SHierarchyNode, int>();
model.NodeKeyPath = “NodeID”;
model.ParentNodePath = “ParentID”;
model.NodesSource = _result;
model.Modifiable = true;
myDiagram.Model = model;


private void Add_Node(object sender, RoutedEventArgs e)
Node selected = myDiagram.SelectedNode;
SHierarchyNode hie=selected.Data as SHierarchyNode;
myDiagram.StartTransaction(“New Node”);
SHierarchyNode newHia = new SHierarchyNode()
Name=“new Group”,
myDiagram.CommitTransaction(“New Node”);

private void Del_Node(object sender, RoutedEventArgs e)
Node selected = myDiagram.SelectedNode;
Node parented = myDiagram.SelectedNode.NodesInto.FirstOrDefault() as Node;
IEnumerable<Node> childs = myDiagram.SelectedNode.NodesOutOf as IEnumerable<Node>;
if (selected != null)
SHierarchyNode selectedHia = selected.Data as SHierarchyNode;
SHierarchyNode parentHia = parented.Data as SHierarchyNode;
myDiagram.StartTransaction(“New Node”);
SHierarchyNode childHia = null;
foreach (Node node in childs)
childHia = node.Data as SHierarchyNode;
childHia.ParentID = parentHia.NodeID;
myDiagram.CommitTransaction(“New Node”);


/***********************Object *********************/
public class SHierarchyNode : TreeModelNodeData<int> { public int _nodeId; public int _parentId; public string _name; public NodeType _type; public int NodeID { get { return _nodeId; } set { if (_nodeId != value) { int old = _nodeId; _nodeId = value; RaisePropertyChanged("NodeID", old, value); } } } public int ParentID { get { return _parentId; } set { if (_parentId != value) { int old = _parentId; _parentId = value; RaisePropertyChanged("ParnetID", old, value); } } } public string Name { get { return _name; } set { if (_name != value) { String old = _name; _name = value; RaisePropertyChanged("Name", old, value); } } } public NodeType NodeType { get { return _type; } set { if (_type != value) { NodeType old = _type; _type = value; RaisePropertyChanged("NodeType", old, value); } } }

I can’t tell what you’re doing in your application.

But if you modify the OrgChartEditor sample by adding this custom dragging tool:

public class CustomDraggingTool : Northwoods.GoXam.Tool.DraggingTool { public override bool IsValidLink(Node fromnode, Node tonode, Link relink) { if (!base.IsValidLink(fromnode, tonode, relink)) return false; // only allow links from someone named "Soprano" -- i.e. only such people can be your new boss Employee fromnodedata = fromnode.Data as Employee; return (fromnodedata != null && fromnodedata.Name.Contains("Soprano")); } }
and then make use of it by replacing the standard Diagram.DraggingTool:

<go:Diagram . . .> <go:Diagram.DraggingTool> <local:CustomDraggingTool DropOntoEnabled="True" /> </go:Diagram.DraggingTool> </go:Diagram>
you’ll see that users are now restricted to reassigning bosses by dropping people only on people with “Soprano” in their name.