Hello.
I want to apply to the way the existing code(Binding IsExpanded).
(TreeView -> xamDataTree)
[TreeView source]
<TreeView x:Name="tv3DModel" ItemsSource="{Binding FirstGeneration}" MouseDoubleClick="TreeView_MouseDoubleClick" Visibility="Visible"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="Foreground" Value="Black" /> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /> <Setter Property="FontWeight" Value="Normal" /> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="FontWeight" Value="Bold" /> </Trigger> </Style.Triggers> </Style> </TreeView.ItemContainerStyle>
<TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Children}"> <DockPanel> <CheckBox IsChecked="True" Uid="{Binding Name}" Visibility="Collapsed"/> <TextBlock Text="{Binding Name}" /> </DockPanel> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView>
[xamDataTree Source]
<ig:XamDataTree Grid.Row="1" x:Name="xdtTreeView" Background="Moccasin"
NodeLineVisibility="Visible" ItemsSource="{Binding FirstGeneration}" ActiveNodeChanged="xdtTreeView_ActiveNodeChanged" IsExpandedMemberPath="{Binding IsExpanded}" > <ig:XamDataTree.SelectionSettings> <ig:TreeSelectionSettings NodeSelection="Single"/> </ig:XamDataTree.SelectionSettings> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="Children" TargetTypeName="JTreeItem" DisplayMemberPath="RefNO" > <ig:NodeLayout.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"><TextBlock Text="{Binding Data.Type}" Width="45" ToolTip="{Binding Data.ViewNameToolTip}"/> <TextBlock Text="{Binding Data.ViewName}" ToolTip="{Binding Data.ViewNameToolTip}"/> </StackPanel> </DataTemplate> </ig:NodeLayout.ItemTemplate> </ig:NodeLayout> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
I want to change only the display Binding Data control.
Hello Igor,
We are constantly striving to make our XAML controls more MVVM friendly and as part of this, we have already started adding an IsSelectedMemberPath property to the XamDataTree. http://ideas.infragistics.com/forums/192363-wpf/suggestions/4812313-xamdatatree-isselectedmemberpath
Rob"]The XamDataTree nodes do not have a bindable property for IsSelected
One can only sadly ask why not?... way to go infragistics btw... Always these stupid custom behaviors. We have observable item with "IsExpanded" but no "IsSelected"?
Inventing a wheel again infragistics?
what the heck?
Hello DongMin Shin,
Let me know if you have any further questions on this matter.
I'm not entirely sure what you are looking for but it seems like you want to perform the same binding you use in the TreeView for the XamDataTree. Is this correct? If so then the first part is already provided to you via the IsExpandedMemberPath property. Your code is using it incorrectly though.
If each of your tree items has an IsExpanded property then all you need to do is set the IsExpandedMemberPath property to the name of the tree item property. (IsExpandedMemberPath="IsExpanded")
The IsSelected property is a bit trickier. The XamDataTree nodes do not have a bindable property for IsSelected so you need to use a behavior in order to simulate a two way binding to the view model's IsSelected property. I actually use two behaviors for this to keep it simple. I have an attached property that is set in the XamDataTreeNodeControl's Style that handles the binding from the view model property to the UI. I then have a behavior attached to the XamDataTree that handles the binding from the UI back to the view model. It's easier this way because the XamDataTree has a SelectedNodesCollectionChanged event.
I have attached a sample that demonstrates this. Let me know if you have any questions on it.