I am following the documentation guide Binding to Dynamic Data with one change, the RadMenu.ItemContainerStyle is set from code and not from XAML.
_menu =
new
RadMenu();
var s = Application.Current.Resources[
"MenuItemStyle"
]
as
Style;
if
(s !=
null
)
{
_menu.ItemContainerStyle = s;
}
The XAML template matches the example, expect for the name of the nested items to match the class used to construct the menu items:
<
ResourceDictionary
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local
=
"clr-namespace:Anvil.Desktop.Windows8"
>
<
Style
x:Key
=
"MenuItemStyle"
TargetType
=
"telerik:RadMenuItem"
>
<
Setter
Property
=
"Header"
Value
=
"{Binding Text}"
/>
<
Setter
Property
=
"ItemsSource"
Value
=
"{Binding Items}"
/>
<
Setter
Property
=
"Icon"
Value
=
"{Binding IconUrl}"
/>
<
Setter
Property
=
"IconTemplate"
>
<
Setter.Value
>
<
DataTemplate
>
<
Image
Source
=
"{Binding}"
Stretch
=
"None"
/>
</
DataTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
ResourceDictionary
>
The resource dictionary is merged and available in the merged resources but the menu items are not rendered as in the with_itemcontainerstyle_set.png attachment and when removing the style setting code:
_menu =
new
RadMenu();
var s = Application.Current.Resources[
"MenuItemStyle"
]
as
Style;
if
(s !=
null
)
{
// _menu.ItemContainerStyle = s;
}
the class names of the menu items are displayed as in without_itemcontainerstyle_set.png
Any suggestions?