<syncfusion:GridTreeControl Name="treeGrid"
AllowDragColumns="True"
AllowDrop="False"
AllowSort="False"
SelectedNode="{Binding Path=SelectedNode,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True,NotifyOnTargetUpdated=True}"
ChildPropertyName="Children"
EnableHotRowMarker="True"
EnableNodeSelection="True"
ExpandStateAtStartUp="AllNodesExpanded"
ItemsSource="{Binding PersonDetails}"
NotifyPropertyChanges="True"
VisualStyle="Metro"
syncfusion:LayoutControl.SetMetroMode="True">
</syncfusion:GridTreeControl>
|
public class InitialSetupBehaviour : Behavior<GridTreeControl>
{
protected override void OnAttached()
{
this.AssociatedObject.Loaded += AssociatedObject_Loaded;
}
private void AssociatedObject_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
this.AssociatedObject.SelectedNodes.CollectionChanged += SelectedNodes_CollectionChanged;
}
private void SelectedNodes_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
var viewModel = this.AssociatedObject.DataContext as ViewModel;
if (e.NewItems != null)
{
viewModel.SelectedNode = (e.NewItems[0] as GridTreeNode).Item;
}
}
protected override void OnDetaching()
{
this.AssociatedObject.Loaded -= AssociatedObject_Loaded;
this.AssociatedObject.SelectedNodes.CollectionChanged -= SelectedNodes_CollectionChanged;
}
} |
<syncfusion:GridTreeControl Name="treeGrid"
AllowDragColumns="True"
AllowDrop="False"
AllowSort="False"
SelectedNode="{Binding Path=SelectedNode,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True,NotifyOnTargetUpdated=True}"
ChildPropertyName="Children"
EnableHotRowMarker="True"
EnableNodeSelection="True"
ExpandStateAtStartUp="AllNodesExpanded"
ItemsSource="{Binding PersonDetails}"
NotifyPropertyChanges="True"
VisualStyle="Metro"
syncfusion:LayoutControl.SetMetroMode="True"/> |