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

3 posts, 0 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 26 Jul 2010 Link to this post

    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. troy
    troy avatar
    20 posts
    Member since:
    Jun 2008

    Posted 28 Jul 2010 Link to this post

    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();
    }

     

  3. DevCraft banner
  4. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 29 Jul 2010 Link to this post

    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.
Back to Top