RadMenu disappears when using Style

4 posts, 1 answers
  1. Abdulkarim
    Abdulkarim avatar
    2 posts
    Member since:
    Sep 2017

    Posted 19 Sep Link to this post

    I'm trying to enable or disable the whole menu based on a value of a variable (i.e., SomeVariable). However, when using Style (in the following xaml) with telerik:RadMenu, the whole menu disappears?

    <telerik:RadMenu.Style>
        <Style TargetType="telerik:RadMenu">
            <Setter Property="IsEnabled"  Value="False" />                                                    
            <Style.Triggers>                                                        
               <DataTrigger Binding="{Binding SomeVariable}"  Value="Draft"> 
                     <Setter Property="IsEnabled"  Value="True" />                                                        
               </DataTrigger>                                                    
            </Style.Triggers>                      
         </Style>                                                                                            
    </telerik:RadMenu.Style>

    Thank you

  2. Answer
    Martin Vatev
    Admin
    Martin Vatev avatar
    129 posts

    Posted 22 Sep Link to this post

    Hello Abdulkarim,

    I guess that the binary files added in your project are NoXAML. If this is the case, an important step to remember is to always base your custom styles on the theme default one when using it. Please take a look at Styling the Controls where you can find detailed information on the matter.

    I hope that this helps.

    Regards,
    Martin Vatev
    Progress Telerik
    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. Abdulkarim
    Abdulkarim avatar
    2 posts
    Member since:
    Sep 2017

    Posted 25 Sep in reply to Martin Vatev Link to this post

    Hello Martin

    Thanks. It works.

    I have a couple of questions:

    1. how to point to the current implemented style in BasedOn property? anything like BasedOn="."? meaning to use whatever theme is being implemented. I have noticed after I have added BasedOn, the text of the menu item turned into black while it was white before. So if there is a way to tell telerik components to use the current implemented one? 

    2. What do you mean by NoXAML? If with XAML, what would be my references? not binary files?

     

    Thank you

  4. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    22 posts

    Posted 28 Sep Link to this post

    Hello Abdulkarim,

    I am going to answer the questions in reverse for better clarification:

    2.The standard(Xaml) binaries include the implementation of the different controls as well as the styles and the resources needed for their visualization. As our assemblies contain multiple components, all styles for them are included and the assembly size is larger.
    The NoXAML binaries, on the other hand, do not include any XAML files - no styles, no brushes or any other resources. This results in smaller assembly size and would mean that when you use them, you have to provide the resources needed for the visualization of the controls.

    1. Given that you are using NoXaml binaries when you create a style that targets a specific control, you should base it on the default style that the theme provides. The naming convention for every control's default style consists of the name of the control followed by a "Style" suffix For you case you can do it like this:

    <Style TargetType="telerik:RadMenu" BasedOn="{StaticResource RadMenuStyle}">
            <Setter Property="IsEnabled"  Value="False" />                                                   
            <Style.Triggers>                                                       
               <DataTrigger Binding="{Binding SomeVariable}"  Value="Draft">
                     <Setter Property="IsEnabled"  Value="True" />                                                       
               </DataTrigger>                                                   
            </Style.Triggers>                     
         </Style>


    You can read more about xaml and NoXaml Binaries in the Setting a Theme article.

    I hope you find this helpful. Let me know if you have any more questions.

    Regards,
    Vladimir Stoyanov
    Progress Telerik
    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