RadMenu Command in Customization example

8 posts, 0 answers
  1. IBST
    IBST avatar
    10 posts
    Member since:
    Feb 2011

    Posted 20 Mar 2011 Link to this post

    I’m trying to implement the radMenu like the Customization example (http://demos.telerik.com/silverlight/#Menu/Customization)

    The exemple does’t show how do we bind the command of the links or special links in the ViewModel. I try to look in your foruns and didn’t get any information about that.

    Can you help me on that?

  2. Dani
    Admin
    Dani avatar
    848 posts

    Posted 21 Mar 2011 Link to this post

    Hi Paulo,

    You can use Commands in your ViewModel in order to make the links fully functional. Use the DelegateCommand class in Telerik.Windows.Controls aseembly to create a custom command that accepts the title of the link as a command parameter and execute the needed redirection in the command itself.
    The FirstLook example of RadContextMenu uses similar approach to execute some actions via Commands.

    I hope this helps.


    Kind regards,
    Dani
    the Telerik team
  3. DevCraft banner
  4. IBST
    IBST avatar
    10 posts
    Member since:
    Feb 2011

    Posted 21 Mar 2011 Link to this post

    Hello,

    I'm sorry, but I'm in the dark here and did not undestand your advise.

    How can I use the DelegateCommand here? That's the main problem...

    I checked the example that you talk about and he use the radMenuClick event in the Code-Behind and then I can send to the ViewModel. The headers are using Localization and can in any language, that's why I can't use this way.

    I try to create a DelegateCommand in the MenuItemViewModel

    public

     

     

    DelegateCommand OnClick { get; set; }
    and in the XAML do this

    <

     

     

    local:MenuItemViewModel Content="List of clients" Type="SpecialLink" OnClick="{Binding ClientListCommand}" />

     


    With this I get an error
    Object of type 'System.Windows.Data.Binding' cannot be converted to type 'Telerik.Windows.Controls.DelegateCommand'.

    Is there a way to do this!?!??!


    regards
    Paulo Aboim Pinto
    project: bizSimplex.com
  5. Dani
    Admin
    Dani avatar
    848 posts

    Posted 22 Mar 2011 Link to this post

    Hi Paulo,

    Attached is a very basic sample illustrating how you can use the DelegateCommand with a basic RadMenu.
     
    Additionally, if your items are localized , you could use one more property in your ViewModel that will provide something similar to an id. You can then pass the value of that property as a command parameter, so that the corresponding command executed method will be able execute any action you need using only that id and regardless of the localization.

    Regards,
    Dani
    the Telerik team
  6. reg
    reg avatar
    6 posts
    Member since:
    Jan 2011

    Posted 07 Apr 2011 Link to this post

    Hi Dani,

    Any chance you could show a sample of how to set the command bindings on the templated RadMenuItems in the example highlighted. I am afraid I cant see how this can be done from the link you posted, as the commands are set on actual menu items in that first look example. Whereas the original question was setting commands against menu items that are created from template items using the ItemsSource binding.

    Thanks
  7. Dani
    Admin
    Dani avatar
    848 posts

    Posted 12 Apr 2011 Link to this post

    Hi Paulo,

    Attached is a sample duplicate of the RadMenu Customization example with Commands. When your items are loaded via the ItemsSource, you need the following: an additional ICommand property in your view model and an additional ContainerBinding for this property in the item template of RadMenu.

    Search for the word "NOTE" to spot the key locations where changes are made.

    I hope this helps.


    Greetings,
    Dani
    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
  8. Fernando
    Fernando avatar
    1 posts
    Member since:
    Feb 2011

    Posted 20 Oct 2011 Link to this post

    Hi Dani...
    you can to send this sample in VB?

    Thanks

    Roger
  9. Dani
    Admin
    Dani avatar
    848 posts

    Posted 25 Oct 2011 Link to this post

    Hello Diego,

    Please, find attached the same project in VB.

    I hope it helps.

    Regards,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top
DevCraft banner