Hi,
I am working with the 'XamDataTree 2010 vol 3', as infragistics previous version lacks a TreeView control I am trying to migrate from my previous standard TreeView to Infragistics XamDataTree (main reason is theming and styling), for my surprise infragistics treeview follows a diferent path than the standard one. Not similar to the Silverlight XamTree which follows a much more common approach compared to the standard treeview.
However, everything resumes to find out how to put all the functionalities together again. My code so far can bind to a collection, display hierarchical information and bind to an 'IsExpanded' property on my view model.
<ig:XamDataTree ItemsSource="{Binding Catalogs}" Grid.Row="1">
<ig:XamDataTree.GlobalNodeLayouts>
<ig:NodeLayout Key="itemLayout" TargetTypeName="TreeViewItemViewModel" IsExpandedMemberPath="IsExpanded">
<ig:NodeLayout.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="{Binding Data.ImagePath}" />
<TextBlock Text="{Binding Data.Name}" />
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
</ig:NodeLayout>
</ig:XamDataTree.GlobalNodeLayouts>
</ig:XamDataTree>
Right now, I am looking forward to bind the XamDataTreeNode item to an IsSelected property on my view model, but I cannot figure out how to target the XamDataTreeNode item.
Any help would be appreciated,
Regards,
Pablo
PS: Sorry about the code snippet formatting.
This video might be helpful to you:
http://blogs.infragistics.com/wpf/media/p/255173.aspx
I had watched the video before. Seems that video is the only info around related to the XamDataTree. The API documentation is useless as it does not provide any sample. As a matter of fact, this is not the only functionality I am looking for, I need to do a lot more of stuffs but I need to be able to target the node item.
Thanks,
I second this request. The control seems to disregard MVVM.
Have you worked around this limitation how did you go about it?
We need to be able to control selection out side of the tree through the view model.
Handling the SelectedNodesCollectionChanged event seems to be the only option.
Inside the handler, I implemented a dirty workaround that breaks MVVM, but you could use something like:
e.OriginalSelectedNodes.Except(e.CurrentSelectedNodes).ForEach(node => ((ViewModelBase)node.Data).IsSelected = false); e.CurrentSelectedNodes.Except(e.OriginalSelectedNodes).ForEach(node => ((ViewModelBase)node.Data).IsSelected = true);
Notes:
1. ForEach() is taken from Microsoft.Practices.EnterpriseLibrary.Common.Utility.EnumerableExtensions.
2. ViewModelBase is the base for all nodes' view model classes.