MVVM Item click

5 posts, 0 answers
  1. Ruban
    Ruban avatar
    21 posts
    Member since:
    Oct 2007

    Posted 05 Oct 2009 Link to this post

    I'm new to Silverlight and MVVM.
    What I'm trying to do is bind an event for the ItemClick for the ContextMenu to the ViewModel.
    It doesn't seem to call the delegate in the viewmodel when I apply to the Telerik Context Menu click but it does work for a standard control such as Hyperlink.
    Any ideas?
    The view:



    UserControl x:Class="Module.Views.PageMenuView"

























    <Grid x:Name="LayoutRoot" Background="White">





    <StackPanel Orientation="Vertical">





    <HyperlinkButton x:Name="SettingLink" Content="Click" cal:Click.Command="{Binding MenuOptionCommand}" Foreground="Blue"/>





    <ToggleButton Content="Export" HorizontalAlignment="Left"




    IsChecked="{Binding IsOpen, ElementName=context, Mode=TwoWay}">










    <telerikNavigation:RadContextMenu x:Name="context" Placement="Bottom" telerikNavigation:RadContextMenu.ContextMenu.="{Binding MenuOptionCommand}">





    <telerikNavigation:RadMenuItem Header="Export to Excel" />





    <telerikNavigation:RadMenuItem Header="Export to PDF" />

































  2. Kaloyan
    Kaloyan avatar
    920 posts

    Posted 09 Oct 2009 Link to this post

    Hi Ruban,

    The Prism Click.Command attached behavior is working only with a Control that has a click event (base type is ButtonBase). The base type of the RadContextMenu is ItemsControl, hence, it is not possible to be attached such a delegate command to the RadContextMenu.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Ruban
    Ruban avatar
    21 posts
    Member since:
    Oct 2007

    Posted 09 Oct 2009 Link to this post

    Found a solution, it is possible by writing a command behavior.
  4. Claudio
    Claudio avatar
    1 posts
    Member since:
    Oct 2010

    Posted 05 Nov 2010 Link to this post

    I have been trying to accomplish the same thing [Get MenuItem that was clicked via a command] and I have found that the Telerik ContextMenu does not support that. Here is an article with source code providing a behavior to get this done.

    However, the date of the arcticle is January, 2010, and I was wondering if this is still the only workaround.

    Thanks in advance,

    Claudio Sanchez
  5. Hristo
    Hristo avatar
    832 posts

    Posted 10 Nov 2010 Link to this post

    Hello Claudio,

    RadMenuItem have Command property of type ICommand as well as CommandTarget and CommandParameter. You can easily bind them to your data item.

    Let us know if you need additional information.

    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
Back to Top