navigation through radtree

3 posts, 0 answers
  1. oburgaya
    oburgaya avatar
    5 posts
    Member since:
    Nov 2012

    Posted 05 Feb 2013 Link to this post

    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. Kiril Vandov
    Admin
    Kiril Vandov avatar
    324 posts

    Posted 08 Feb 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. oburgaya
    oburgaya avatar
    5 posts
    Member since:
    Nov 2012

    Posted 08 Feb 2013 Link to this post

    That's exactly what I need! Thanks
Back to Top