SeyoS
SeyoS

Reputation: 681

MenuItem's sub menu don't open

I have a MenuItem with sub-buttons in a ToolBar:

<ToolBar x:Name="toolBar" VerticalAlignment="Top">
      <Button x:Name="btnNew" Content="New"/>
      <MenuItem x:Name="miWindow" Header="Add windows">
             <Button x:Name="btnScore1" Content="Score"/>
             <Button x:Name="btnScore2" Content="Score (complete)"/>
      </MenuItem>
 </ToolBar>

When I click on it, my sub-menu don't open. Did I forget something ?

Also, I tried to handle the click event of the MenuItem, but it's never fired.

Upvotes: 1

Views: 115

Answers (1)

Salah Akbari
Salah Akbari

Reputation: 39946

It should be inside a Menu Tag:

<ToolBar x:Name="toolBar" VerticalAlignment="Top">
    <Button x:Name="btnNew" Content="New"/>
    <Menu>
        <MenuItem x:Name="miWindow" Header="Add windows">
            <Button x:Name="btnScore1" Content="Score"/>
            <Button x:Name="btnScore2" Content="Score (complete)"/>
        </MenuItem>
    </Menu>
</ToolBar>

Upvotes: 3

Related Questions