This is a migrated thread and some comments may be shown as answers.

How to close RadMenu when some object inside a RadMenuItem is clicked...

2 Answers 62 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 26 Jul 2010, 09:53 PM
Let's say I have RadMenu that has an ItemTemplate defined like this...

<Rad:HierarchicalDataTemplate x:Key="it">
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="21" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>
    <StackPanel Orientation="Horizontal">
      <TextBlock Content="{Binding MyCaption}" />
      <Button Content="Button1" Command="..." CommandParameter="..." />
      <Button Content="Button2" Command="..." CommandParameter="..." />
    </StackPanel>
  </Grid>
</Rad:HierarchicalDataTemplate>

The RadMenuItem's will have a textblock followed by two buttons.  I can click on the RadMenuItem and the RadMenu will behave normally, however, if I click on the buttons, I would also like the RadMenu to close.  How can I accomplish this?



2 Answers, 1 is accepted

Sort by
0
troy
Top achievements
Rank 1
answered on 28 Jul 2010, 04:54 PM
this is the only way I found to accomplish it... this is basically just invoking the default behavior of the root menu item... which happens to be close if it's open.  hope it helps.

troy


 

 

void btn_Click(object sender, RoutedEventArgs e)
{
RadMenuItemAutomationPeer mip = new RadMenuItemAutomationPeer(menuItemRoot);
mip.Invoke();
}

 

0
Rob
Top achievements
Rank 1
answered on 29 Jul 2010, 08:05 PM
I ended up just rearranging my menu items instead.  I'm wary about having to add click events all over just to close the menu.
Tags
Menu
Asked by
Rob
Top achievements
Rank 1
Answers by
troy
Top achievements
Rank 1
Rob
Top achievements
Rank 1
Share this question
or