Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
HTML
<Menu Height="30" Name="menu1" VerticalAlignment="Top" BorderThickness="2"
            Foreground="White" FontSize="16" FontWeight="Bold" Margin="-2,-2,0,0" Grid.RowSpan="2" Grid.ColumnSpan="66">
          <Menu.Background>
              <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                  <GradientStop Color="#FF3A60AD" Offset="0.528"/>
                  <GradientStop Color="#FF6A85D8" Offset="0.01"/>
                  <GradientStop Color="#FF3464C4" Offset="1"/>
                  <GradientStop Color="#FF202E7E" Offset="1"/>
              </LinearGradientBrush>
          </Menu.Background>
          <Menu.BitmapEffect>
              <DropShadowBitmapEffect />
          </Menu.BitmapEffect>
          <MenuItem Header="File" IsCheckable="True" Click="MenuItem_Click">
              <MenuItem Header="Open" IsCheckable="true">
                  <MenuItem.ToolTip>
                      <ToolTip>
                          Open a file.
                      </ToolTip>
                  </MenuItem.ToolTip>
              </MenuItem>
              <MenuItem Header="_Close" IsCheckable="true"/>
              <MenuItem Header="_Save" IsCheckable="true"/>

              <Separator/>
              <MenuItem Header="Sub Items">
                  <MenuItem Header="Child1 SubItem" IsCheckable="true"/>
                  <MenuItem Header="Child2 SubItem" IsCheckable="true">
                      <MenuItem Header="GrandChild2 SubItem" IsCheckable="true"/>
                  </MenuItem>
              </MenuItem>

          </MenuItem>
          <MenuItem Header="Settings" IsCheckable="true" Foreground="Orange" FontSize="16" >

          </MenuItem>
          <MenuItem Header="Security" IsCheckable="true" Foreground="White" FontSize="16">

          </MenuItem>
          <MenuItem Header="Database" IsCheckable="true" Foreground="LightGreen" FontSize="16">


          </MenuItem>
      </Menu>


the code do not work as it expected. ie when I click the menu Tools (or any other menu item)it is only getting checked it do not show any submenu. please somebody help me

thanks in advance
Posted
Updated 15-Jan-12 10:54am
v2

1 solution

The problem is in IsCheckable="true". Remove this attribute if you need child items. A menu item can ether act as a ItemsConrol with visible children or checkable, not both at the same time. If you think about it you will see that doing both things makes no sense.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900