Menu not closed

10 posts, 0 answers
  1. sum sum
    sum sum avatar
    21 posts
    Member since:
    Nov 2009

    Posted 16 Nov 2009 Link to this post

    HI guys,

    I have menu items inside a dropdown button. Menus are bound to commands. The issue is once the item is clicked, commands are fired; but the menus are not closed afterwards. I have to click somewhere on the screen to make it close. How can I close the menu in the commands fired events?

    thanks,
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 17 Nov 2009 Link to this post

    Hi,

    Instead of placing ContextMenu in a DropDown button I would recommend using the code from the following blog post, where the ContextMenu will close itself automatically:
    http://blogs.telerik.com/valerihristov/posts/09-09-07/drop-down_menu_button_with_telerik_contextmenu_for_silverlight.aspx

    Kind regards,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WPF is Visual Studio 2017 Ready
  4. sum sum
    sum sum avatar
    21 posts
    Member since:
    Nov 2009

    Posted 17 Nov 2009 Link to this post

    Hi Guys,

    If implementing ItemClick event, the menu closes. However, it is not closed when  binding menu items to commands. The sample you gave me is still ItemClick event.

  5. Chris
    Chris avatar
    17 posts
    Member since:
    Nov 2009

    Posted 05 Feb 2010 Link to this post

    Hi

    I have a similar problem and it is driving me nuts. Is there any resolution on this.

    Here is my xaml. The command fires fine but the RadMenu stays open. It works if I handle the Click Event but I want my logic in the Presenter and not in the code behind.

    <trn:RadMenu DockPanel.Dock="Top" x:Name="ConnectMenu" VerticalAlignment="Top" ClickToOpen="True">  
                <trn:RadMenuItem Header="Connect" ToolTip="Connect to e5 Instance" ItemsSource="{Binding Path=Instances}" > 
                    <trn:RadMenuItem.ItemTemplate> 
                        <DataTemplate> 
                            <trn:RadMenuItem Command="{Binding DataContext.ConnectCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type trn:RadMenu}}}"   
                                                       CommandParameter="{Binding Path=.}" 
                                             Header="{Binding Path=Name}" StaysOpenOnClick="False"/>  
                        </DataTemplate> 
                    </trn:RadMenuItem.ItemTemplate> 
                </trn:RadMenuItem> 
            </trn:RadMenu> 

    thanks
  6. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 05 Feb 2010 Link to this post

    Hello Chris Wessels,

    RadMenu doesn't close because you are placing RadMenuItems in RadMenuItem - from the DataTemplate.
    Instead of ItemTemplate you should use ItemContainerStyle to apply style for dynamically created items and bind their properties in Style setters. Like this:
    <trn:RadMenuItem.ItemContainerStyle>
        <Style TargetType="trn:RadMenuItem">
            <Setter Property="Command"
                    Value="{Binding DataContext.ConnectCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type trn:RadMenu}}}" />
            <Setter Property="CommandParameter" Value="{Binding Path=.}" />
            <Setter Property="Header" Value="{Binding Path=Name}" />
            <Setter Property="StaysOpenOnClick" Value="False" />
        </Style>
    </trn:RadMenuItem.ItemContainerStyle>

    Let us know if you need more help.

    Best wishes,
    Hristo
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  7. Chris
    Chris avatar
    17 posts
    Member since:
    Nov 2009

    Posted 07 Feb 2010 Link to this post

    Hi Hristo

    Thanks so much for the quick response - that works beautifully. :-)

    Regards
    Chris
  8. Calvin
    Calvin avatar
    12 posts
    Member since:
    Jun 2010

    Posted 07 Dec 2010 Link to this post

    Are you suggesting that it is impossible to close a menu whenever MenuItems are nested within other MenuItems?   Is is possible to see the complete working project for the code snippet which you provide? 

    I am using the Q2 RadMenu control. 

    Thanks.
  9. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 09 Dec 2010 Link to this post

    Hi Calvin,

    You missed the context of the previous communication. If you take a look in the xaml you will see that the usage was incorrect.
    RadMenu will close no matter which item you click.

    Let us know if you need more details.

    Regards,
    Hristo
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  10. Calvin
    Calvin avatar
    12 posts
    Member since:
    Jun 2010

    Posted 09 Dec 2010 Link to this post

    I'll be happy to admit that I don't fully understand this issue which is why I asked my question.  I'll even admit that when I look at the xaml I do not see that the usage is incorrect which is why I asked if it is or is not OK to nest MenuItems within other MenuItems.  My Menu does not use a DataTemplate.  Every MenuItem contains the property  StaysOpenOnClick="False"

    My Menu does not close no matter which item I click.  In other respects, it functions as I would expect it. 

    Thanks.
  11. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 10 Dec 2010 Link to this post

    Hello Calvin,

    Could you please post the XAML declaring RadMenu and its items?
    This way I will be able to help you faster.

    All the best,
    Hristo
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
Back to Top
UI for WPF is Visual Studio 2017 Ready