Q:

Bind Menuitems to a collection, make them checkable and style the

I want to bind the subitems of a menu to a collection and then be able to style them and make them selectable in the way of a radiobutton (Only one should be selected at a time). This is what I have so far
<MenuItem Header="League" Style="{StaticResource MenuItemStyle}" ItemsSource="{Binding AvailableLeagues}">
            <MenuItem.ItemContainerStyle>
                <Style>
                    <Setter Property="MenuItem.Header"
          Value="{Binding InAppName}" />
                </Style>
            </MenuItem.ItemContainerStyle>
        </MenuItem>

It works so far that all the items in the collection are visible as menuitems. But I can't apply a style to them and i can't make them checkable. The "MenuItemStyle" only applies to the outer menu item but not to the children.
Do i have to redefine the popup of the outer menuitem to something like a list of radiobuttons(wouldn't know exactly how to do this)  or is there a solution with menuitems?
Thx in advance

A:

This method applies a style to a MenuItem and all of its children, and their children, recursively:
<MenuItem Header="Main Menu Item">
    <MenuItem Header="Unaffected Sibling" />

    <MenuItem Header="Foo">
        <MenuItem.Resources>
            <Style TargetType="MenuItem">
                <Setter Property="MenuItem.Header" Value="{Binding InAppName}" />
                <Setter Property="IsCheckable" Value="True" />
                <Setter Property="IsChecked" Value="{Binding IsSomeRandomBoolProperty}" />

                <Setter Property="Background" Value="YellowGreen" />
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="Foreground" Value="Red" />
            </Style>
        </MenuItem.Resources>
        <MenuItem Header="Bar" />
        <MenuItem Header="I Am Damo Suzuki">
            <MenuItem Header="Blah blah blah">
                <MenuItem Header="Amon Duul II" />
            </MenuItem>
        </MenuItem>
    </MenuItem>
</MenuItem>

