This question is locked. New answers and comments are not allowed.
In xaml, I created a RadMenu and added a couple of RadMenuItems. I also created a style for RadMenuItem and applied the style to each of the RadmenuItems added in the xaml.
xaml:
xaml:
<UserControl.Resources>
...
<Style x:Key="RadMenuItemStyle1" TargetType="telerik:RadMenuItem">
Other than the RadMenuItems added in xaml, I have to add extra RadMenuItems at run-time. I can add the RadMenuItem at run-time, but I have difficulties applying the style created in xaml to the dynamically added RadMenuItem. Is it possible? If so, how?
code-behind:
RadMenuItem newItem = new RadMenuItem();
...
<Style x:Key="RadMenuItemStyle1" TargetType="telerik:RadMenuItem">
...
</Style>
</UserControl.Resources>
<telerik:RadMenu>
<telerik:RadMenuItem Header="Item 1" Name="Item1">
<telerik:RadMenuItem Header="Sub Item 1" Style="{StaticResource RadMenuItemStyle1}" />
<telerik:RadMenuItem Header="Sub Item 2" Style="{StaticResource RadMenuItemStyle1}" />
</telerik:RadMenuItem>
</telerik:RadMenu>
...
Other than the RadMenuItems added in xaml, I have to add extra RadMenuItems at run-time. I can add the RadMenuItem at run-time, but I have difficulties applying the style created in xaml to the dynamically added RadMenuItem. Is it possible? If so, how?
code-behind:
RadMenuItem newItem = new RadMenuItem();
newItem.Header = "Newly added item";
//newItem.Style = how to reference the style created in xaml???
this.Item1.Items.Add(newItem);
Thank you in advance!