This is a migrated thread and some comments may be shown as answers.

navigation through radtree

2 Answers 83 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
oburgaya
Top achievements
Rank 2
oburgaya asked on 05 Feb 2013, 02:51 PM
Hello,

I want to implement navigation through MVVM in a WPF aplication using RadTree.

I want to do that, when someone clicks over an item of the tree, the VM executes a Command to change the active view in another prism region.

¿Can you help me with that? I don't know to which element in xaml need to attach the Command, if the RadTree is Binding to an Observable Collection of the VM.

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 08 Feb 2013, 02:42 PM
Hello Xsunyer,

In order to bind to a Command defined in the RadTreeView.DataContext (in your case the VM), not in the ViewModels of each child, you could set the ItemContainerStyle property of the RadTreeView and bind to the Command property of the RadTreeViewItem like follows:
- first define your VM like a StaticResource in the Window.Resources
<Window.Resources>
    <viewModels:MainViewModel x:Key="viewModel" /> 
...
- next create the custom ItemContainerStyle:
<Style TargetType="telerik:RadTreeViewItem" x:Key="CustomContainerStyle">
    <Setter Property="Command" Value="{Binding GlobalCommand, Source={StaticResource viewModel}}" />
</Style>
this way you bind each RadTreeViewItem Command property to a business command defined in the main VM.

I hope this information helps.

Kind regards,
Kiril Vandov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
oburgaya
Top achievements
Rank 2
answered on 08 Feb 2013, 04:02 PM
That's exactly what I need! Thanks
Tags
TreeView
Asked by
oburgaya
Top achievements
Rank 2
Answers by
Kiril Vandov
Telerik team
oburgaya
Top achievements
Rank 2
Share this question
or