I have a context menu and i want its menu items populated via a binding. The following code works
<Button>
<controlsInputToolkit:ContextMenuService.ContextMenu>
<controlsInputToolkit:ContextMenu ItemsSource="{Binding MenuItems}">
<controlsInputToolkit:ContextMenu.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</controlsInputToolkit:ContextMenu.ItemTemplate>
</controlsInputToolkit:ContextMenu>
</controlsInputToolkit:ContextMenuService.ContextMenu>
</Button>
but there's one problem, the ItemTemplate represents the Text area of a menu item and so as far as im aware doesnt allow you to set the icon
so i tried doing the binding via the ItemContainerStyle as in the below example
<Button>
<controlsInputToolkit:ContextMenuService.ContextMenu>
<controlsInputToolkit:ContextMenu ItemsSource="{Binding MenuItems}">
<controlsInputToolkit:ContextMenu.ItemContainerStyle>
<Style TargetType="controlsInputToolkit:MenuItem">
<Setter Property="Header" Value="{Binding Name}"/>
</Style>
</controlsInputToolkit:ContextMenu.ItemContainerStyle>
</controlsInputToolkit:ContextMenu>
</controlsInputToolkit:ContextMenuService.ContextMenu>
</Button>
but silverlight doesnt seem to like that
any ideas?