This is a migrated thread and some comments may be shown as answers.

RadMenu disappears when using Style

4 Answers 38 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Abdulkarim
Top achievements
Rank 1
Abdulkarim asked on 20 Sep 2017, 04:25 AM

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

4 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 22 Sep 2017, 10:14 AM
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 you to write beautiful native mobile apps using a single shared C# codebase.
0
Abdulkarim
Top achievements
Rank 1
answered on 25 Sep 2017, 07:53 AM

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

0
Vladimir Stoyanov
Telerik team
answered on 28 Sep 2017, 07:49 AM
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.
0
Abdulkarim
Top achievements
Rank 1
answered on 14 Aug 2018, 03:31 AM
thank you very much for the explanations
Tags
Menu
Asked by
Abdulkarim
Top achievements
Rank 1
Answers by
Martin
Telerik team
Abdulkarim
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or