MenuItem popup close when open new floating pane

6 posts, 0 answers
  1. Gregorio
    Gregorio avatar
    3 posts
    Member since:
    Apr 2017

    Posted 22 Jun Link to this post

    Hello

    I want still opening MenuItem's popup when I open new floating pane by ToolWindow.

    for example, VisualStudioDocking_WPF in Docking example source code, it worked I expected.

    in that sample,

    1. ToolBox pane, make a floating pane.

    2. Open View 's menu popup in Menu bar.

    3. Repeat click to ToolBox item in popup. (check and uncheck).

    then also open and close ToolBox pane(floating) and View's menu item popup still opened. (that's exactly what I want)

    It is implemented by RadMenuItem in MenuBars.

     

    And I implemented like VisualStudioDocking_WPF sample, but I didn't use RadMenuItem, using WPF control MenuItem and set StaysOpenOnClick="True".

    Then docked panes doesn't matter. (still opened menu item's popup)

    But floating panes not worked what I want.(Popup close when open or close floating pane)

    - I guess MenuItem lost focus when open or close floating pane, so popup also closed.-

    I want still open popup like VisualStudioDocking_WPF sample.

    How can I get it without RadMenuItem?

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1408 posts

    Posted 27 Jun Link to this post

    Hi Gregorio,

    Can you share some runnable code demonstrating your set up? This way I can check it on my side and see if I can think of a possible solution.

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Gregorio
    Gregorio avatar
    3 posts
    Member since:
    Apr 2017

    Posted 27 Jun in reply to Martin Ivanov Link to this post

    Hi Martin

    https://github.com/shwlee/MenuPopupSample.git

    this is a sample source clone url that I created like VisualStudioDocking_WPF example.

    In this source, I used WPF Menu control instead of RadMenu control.

    There is same test procedure that I said first post in this thread.

    thank you for your reply

     

  4. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1408 posts

    Posted 30 Jun Link to this post

    Hello Gregorio,

    Thank you for the project. 

    The described behavior appears because the tool window gets activated which closes the WPF native Menu. On the other hand the RadMenu has logic that prevents this behavior and the menu can stay open even if it loses the focus. Can you tell me why you need to use the native Menu? I would recommend you to use the RadMenu control because it has better integration with other Telerik controls and an extended set of features. 

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Gregorio
    Gregorio avatar
    3 posts
    Member since:
    Apr 2017

    Posted 03 Jul in reply to Martin Ivanov Link to this post

    Hi Martin

     

    I understood that's the reason for native WPF menu why it closed.

    There is my team policy that reduce 3rd party assembly dependency. This is reason why I need native WPF control.

    I use RadMenu, but didn't use RadMenu's special feature, use just like native WPF menu control. So I thought I can change from RadMenu to native WPF menu, and I face a this problem.

    But if it is too complicated or can't change, I will keep going to use Telerik libraries, such as Map, Docking, Chart etc...

    So I wonder exactly that is possible to still open native WPF MenuItem popup when Tool window opened or closed.

    Could you get me some help?

  6. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1408 posts

    Posted 06 Jul Link to this post

    Hello Gregorio,

    To achieve your requirement you can write some custom code. Basically, you will need to make sure that the menu doesn't close when it lost the focus. A possible approach could be to capture the mouse with the menu items when the mouse is pressed and release it when up. Here is an example in code:
    EventManager.RegisterClassHandler(typeof(MenuItem), MenuItem.MouseLeftButtonDownEvent, new RoutedEventHandler(OnMenuItemMouseLeftButtonDown));
                EventManager.RegisterClassHandler(typeof(MenuItem), MenuItem.MouseLeftButtonUpEvent, new RoutedEventHandler(OnMenuItemMouseLeftButtonUp));
     
    //------
    private void OnMenuItemMouseLeftButtonUp(object sender, RoutedEventArgs e)
    {
        Dispatcher.BeginInvoke(new Action(() => {
            var item = (MenuItem)sender;
            item.ReleaseMouseCapture();
        }));
    }
     
    private void OnMenuItemMouseLeftButtonDown(object sender, RoutedEventArgs e)
    {           
        var item = (MenuItem)sender;
        item.CaptureMouse();           
    }

    I hope this helps.

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top