Why cann't RadContextMenu bind to a data context command ??

6 posts, 0 answers
  1. Carlos
    Carlos avatar
    14 posts
    Member since:
    Feb 2012

    Posted 08 Aug 2013 Link to this post

    I spent 2+hrs trying to get some simple binding with the RadContextMenu.

    Trying to Bind a command and a title. It never works.

    Problem like this with your rad controls are making me waste hours!  

    Why can it bind to a data context command ?? 

    <Image Source="/Images/appbar.list.png">
        <telerikPrimitives:RadContextMenu.ContextMenu>
            <telerikPrimitives:RadContextMenu IsOpen="{Binding IsChecked, ElementName=ctrlBtnOpenPopup, Mode=TwoWay}">
                <telerikPrimitives:RadContextMenuItem  Content="{Binding Title}" Command="{Binding PodPageViewModel.CmdMarkEpisodeShare, Mode=OneWay}">
                </telerikPrimitives:RadContextMenuItem>
            </telerikPrimitives:RadContextMenu>
        </telerikPrimitives:RadContextMenu.ContextMenu>
    </Image>

  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 13 Aug 2013 Link to this post

    Hi Carlos,

    Thanks for writing.

    Based on the XAML snippet you are sharing we cannot exactly say what happens. Most probably the DataContext you are binding against is not correct. Can you please make sure the data context that is assigned to the context menu is the one which is expected?

    It will also be useful if you can send us a sample which reproduces the issue or your entire project for further investigation. You will have to open a new support ticket in order to be able to do that.

    Thanks for your time.

    Regards,
    Deyan
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
  4. Carlos
    Carlos avatar
    14 posts
    Member since:
    Feb 2012

    Posted 14 Aug 2013 Link to this post


    The DataContext is correct.  I missed to tell you that the menu is within a datatemplate.

    to recreate:

    - Create a DataTemplate with context menu elements (somethin like my xaml)
    - Set as content template in a ContenControl  
    - Set proper context in the content control (with the command to bind to)

    No binding occurs...

    What's the problem ? 

    thanks
  5. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 19 Aug 2013 Link to this post

    Hi Carlos,

    The reason for this behavior is that the Context menu is inserted at root level in your page. The data context that you are setting is therefore not accessible by the items.

    Try directly setting the DataContext property of the ContextMenu instead.

    I hope this helps.

    Regards,
    Deyan
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  6. Carlos
    Carlos avatar
    14 posts
    Member since:
    Feb 2012

    Posted 20 Aug 2013 Link to this post

    thanks for your feedback. I will re-visit this code soon and try your suggestion
  7. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 23 Aug 2013 Link to this post

    Hi Carlos,

    We will consider your thread closed for now.

    Feel free to reopen it in case of further questions.

    Regards,
    Deyan
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Back to Top
DevCraft banner