none
Can a checkable menuitem have children?

    Question

  • I seem to be unable to add items to a menuitem that is checkable.

    Some example code:

    <Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="TEST.MainWindow"
        x:Name="Window"
        Title="MainWindow"
        Width="640" Height="480">

        <Grid x:Name="LayoutRoot">
            <Menu>
                <MenuItem Header="MenuItem" x:Name="Root">
                    <MenuItem Header="MenuItem" IsCheckable="True" x:Name="Parent">
                        <MenuItem Header="MenuItem" x:Name="Child"/>
                    </MenuItem>
                </MenuItem>
            </Menu>
        </Grid>
    </Window>

    The menuitem called Parent hides the child menuitem if IsCheckable = true. Is this by design?
    What i'm looking for is to use the menuitem named parent like a category where one should be able to check it and all it's child elements and vice versa.
    I would appriciate it if someone could explain this behaviour to me.

    Cheers
    Mod
    • Edited by modplug Monday, November 30, 2009 12:18 PM Added example code and further explenation
    Monday, November 30, 2009 10:29 AM

Answers

  • That is by design as far as I'm aware.  If what you're looking to do is a basic select/deselect all type functionality then you can set the children to checkable and use a trigger for the parent menu item to set the children to checked or unchecked accordingly.  If that's not what you were looking to do, please explain.
    If at first you don't succeed, skydiving is definitely not for you!
    Tuesday, December 01, 2009 3:09 AM