ItemContainerItemContainerStyle Property Breaks RadContextMenu

4 posts, 0 answers
  1. Scott
    Scott avatar
    10 posts
    Member since:
    Apr 2016

    Posted 22 Mar Link to this post

    I am trying to bind a RadContextMenu to dynamic data. For now though I am simply creating three items in the initialization method.

    When I run the code WITHOUT having set the ItemContainerStyle in the RadContextMenu, I get a ContextMenu, however the text being displayed is the class name of the item being bound (see attached file for example)

    When I insert the ItemContainerStyle in the XAML, nothing is displayed. However, in the "Opened" event of the RadContextMenu, I do see that the menu is "trying" to open yet nothing is ever displayed.

    Without ItemContainerStyle, I get a pop-up with the class name of the items.

    With ItemContainerStyle, I get nothing.

    Here is the code wireup:

    XAML in the UserControl where the RadContextMenu is defined:

    <telerik:RadContextMenu.ContextMenu>
        <telerik:RadContextMenu x:Name="WorkListContextMenu"
                                ItemsSource="{Binding WorkListContextMenuItems}"
                                Opened="WorkListContextMenu_Opened">
     
            <telerik:RadContextMenu.ItemContainerStyle>
                <Style TargetType="telerik:RadMenuItem">
                    <Setter Property="Header" Value="{Binding Header}" />
                    <Setter Property="ItemsSource" Value="{Binding SubItems}" />
                    <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
                    <Setter Property="IsChecked" Value="{Binding IsChecked}"/>
                </Style>
            </telerik:RadContextMenu.ItemContainerStyle>
     
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>

     

    When I comment out the "telerik:RadContextMenu.ItemContainerStyle" section, the pop-up appears, but with the classname of the ItemsSource Binding objects.

    Not sure what I can do, I've researched for two days now and cannot find the solution. Can someone please offer a suggestion as to what I'm doing wrong?

     

  2. Kalin
    Admin
    Kalin avatar
    1279 posts

    Posted 23 Mar Link to this post

    Hello Scott,

    I assume you are using Implicit Styles - in this case you would need to base the custom Style to default RadMenuItem Style. Try the following and let me know if it helps:


    <telerik:RadContextMenu.ItemContainerStyle>
        <Style TargetType="telerik:RadMenuItem" BasedOn="{StaticResource RadMenuItemStyle}">
            <Setter Property="Header" Value="{Binding Header}" />
            <Setter Property="ItemsSource" Value="{Binding SubItems}" />
            <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
            <Setter Property="IsChecked" Value="{Binding IsChecked}"/>
        </Style>
    </telerik:RadContextMenu.ItemContainerStyle>

    Hope this will solve the issue. If not - I would like to ask you to open up a support ticket and attach a sample project reproducing the scenario.

    Regards,
    Kalin
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Scott
    Scott avatar
    10 posts
    Member since:
    Apr 2016

    Posted 23 Mar in reply to Kalin Link to this post

    The BasedOn="{StaticResource RadMenuItemStyle}" absolutely fixed this. I had opened a ticket but now have marked it as resolved.

    Thank you for getting this information to me. I would like to point out that hours of research on this, including Telerik's own documentation NEVER revealed this attribute is necessary.

  4. Kalin
    Admin
    Kalin avatar
    1279 posts

    Posted 24 Mar Link to this post

    Hi Scott,

    I'm glad this solved the issue. For more details regarding Implicit Styles and applying custom styles, please check the following articles from our help documentation:
    http://docs.telerik.com/devtools/wpf/styling-and-appearance/styling-apperance-setting-a-theme-overview
    http://docs.telerik.com/devtools/wpf/styling-and-appearance/styling-apperance-styling-the-controls

    If you have any other questions or concerns, please let us know.

    Regards,
    Kalin
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top