Hello,
I have a data class like this:
public class UICameraTree : NotificationObject{ private string _stakeholderName; private ObservableCollection<UICamera> _cameraList = new ObservableCollection<UICamera>(); private ObservableCollection<UICameraTree> _cameraTree = new ObservableCollection<UICameraTree>();
public string StakeHolderName { get { return _stakeholderName; } set { _stakeholderName = value; base.RaisePropertyChanged(() => StakeHolderName); } } public ObservableCollection<UICamera> CameraList { get { return _cameraList; } } public ObservableCollection<UICameraTree> CameraTree { get { return _cameraTree; } }}
And XAML like:
<ig:XamDataTree x:Name="CameraDataTree" Grid.Row="1" Style="{StaticResource DASXamDataTree}" ItemsSource="{Binding UICameraTree.CameraTree}" IsDraggable="True"> <ig:XamDataTree.CheckBoxSettings> <ig:CheckBoxSettings CheckBoxVisibility="Hidden" /> </ig:XamDataTree.CheckBoxSettings> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="GroupLayout" TargetTypeName="UICameraTree" DisplayMemberPath="StakeHolderName"/> <ig:NodeLayout Key="ItemLayout" TargetTypeName="UICamera" DisplayMemberPath="CameraList\CameraName /> </ig:XamDataTree.GlobalNodeLayouts></ig:XamDataTree>
How can I get rid off "GroupLayout" and "ItemLayout" from the tree?
Thank you!
David
Hello David,
Thank you for the sample. I believe that the XamDataTree shows the keys of the layouts as nodes because the XamDataTree is designed to display different kind of objects within the same level if it uses different layouts. So when it is needed it shows the keys for this layout.
Regarding your issue I modified the sample you sent me by setting the triggers in the style of XamDataTreeNodeControl, which will collapsed the nodes you don’t want to be shown. Also I handled the PreviewMouseDown of the ExpansionIndicator, so when you click on the arrows the expansion for the nodes is still working as expected. To achieve the desired functionality I modify the default templates for the XamDataTreeNodeControl in order to attach the new style for the ExpansionIndicator and to hide the unnecessary lines.
If you need any further assistance on the matter, please do not hesitate to ask.
Elena,
I've attached some sample code of what we're using...
Thanks,
Hello Elena,
Thanks for the fix, but I have a few concerns: :(
1. Nodes are always expanded and indentation is now twice bigger.
2. The biggest concern is that, why is XamDataTree not able to handle the structure automatically?
I reviewed your issue and I can suggest you set a style for the XamDataTreeNodeControl and in the style to modify the height of the nodes where the Content equals “ItemLsayout” or “GroupLayout”. Before hiding this nodes you can ensure that you have already expanded their hierarchies because after hiding them their expansionindicator will be hidden too. You may try the following code snippet to achieve this functionality:
<Style TargetType="{x:Type ig:XamDataTreeNodeControl}">
<EventSetter Event="Loaded" Handler="CameraDataTree_Loaded"/>
<Style.Triggers>
<Trigger Property="Content" Value="GroupLayout">
<Setter Property="Height" Value="0"/>
</Trigger>
<Trigger Property="Content" Value="ItemLayout">
<Setter Property="Height" Value="0" >
</Setter>
</Style.Triggers>
</Style>
private void CameraDataTree_Loaded(object sender, RoutedEventArgs e)
{
(sender as XamDataTreeNodeControl).Node.IsExpanded = true;
}
If you need any further assistance on this, please do not hesitate to ask.