Commanding with TreeViewItems

3 posts, 0 answers
  1. Scott Taylor
    Scott Taylor avatar
    1 posts
    Member since:
    Dec 2009

    Posted 24 Feb 2010 Link to this post

    I'm trying to use the TreeViewItem in a RadOutlookBar to provide a navigation system for my app.

    I'm trying to use Commands in a MVVM pattern to launch the views...

    TreeViewItem lacks a Command property.. is there a way to do this?
  2. Miro Miroslavov
    Miro Miroslavov avatar
    588 posts

    Posted 26 Feb 2010 Link to this post

    Hello Scott Taylor,

    We replay to your support ticket. I'm pasting this to allow others to it,a s well.

    The TreeViewItems indeed do not have built-in support for commands.

    If you are binding the TreeView you can use an ItemTemplate that contains buttons which have their command property set.

    If the TreeView is  defined in Xaml you can assign the Header property of the TreeViewItem some kind of content that contains a button.

    Sincerely yours,
    Miro Miroslavov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. k f
    k f avatar
    109 posts
    Member since:
    Jun 2006

    Posted 20 Mar 2010 Link to this post

    Hello Scott,

    You can build your own code to support commanding in any UI Element that doesn't natively support commanding.

    I'm starting a community specifically for MVVM, Prism, MEF type discussions.

    In particularly, pull down the code from Lesson 4 Prism NW Databinding & Commands.

    From that code, pull out the NSVMVVM assembly.  This assembly is mostly code from Sacha Barbers Cinch framework.  However, the code I use in it to implement commanding in elements that don't support it natively, I pulled from Jeff Brands training series.

    Please check out  I consulted with a couple of persons from Telerik and we thought it would be a good idea to have a central place to discuss MVVM, Prism etc.  The site is just being started so if you check it out and have any suggestions about the layout.  Have any thing you'd like to see a demo of, if I have time I'll consider adding it as a lesson.


    P.S.  A sample of xaml wiring up a custom command to a Non-command UI element would look somethng like this using the code in the link I sent you.  

    <telerik:RadComboBox MinWidth="150" Name="RCmbCustomers" IsTextSearchEnabled="True"
                    nsvmvvm:CommandBehavior.TheCommandToRun="{Binding Path=SelectedCustomerCommand}"                       
                    nsvmvvm:CommandBehavior.CommandParameter="{Binding ElementName=RCmbCustomers, Path=SelectedItem}"
                    ItemsSource="{Binding Source={StaticResource CustomerModels}}"
                    ItemTemplate="{StaticResource CustomerCmbTemplate}"
Back to Top