radSpiltButton: prevent dropdown from closing on enter

2 posts, 0 answers
  1. jen
    jen avatar
    60 posts
    Member since:
    Jun 2009

    Posted 19 Apr Link to this post

    I have a radSpiltButton with a simple search form in the drop down content. When the user hits enter I want a button on that form to be triggered (isDefault=true), however the enter is closing the drop down content.  How can I keep the content open when the user hits enter?


    There doesn't seem to be a cancelable DropDownClosing event that I can cancel, so I tried checking for the pressed key in the DropDownClosed event. If the key is the enter key then I try to re-open the drop down. I received an error: "Cannot reopen a popup in the closed event handler."

    private void splt_Customer_DropDownClosed(object sender, RoutedEventArgs e)
                if (Keyboard.IsKeyDown(Key.Return))
                    splt_Customer.IsOpen = true;
                  // Error: "Cannot reopen a popup in the closed event handler."


    I can't re-open the drop down content once its been closed; so how do I prevent it from closing on enter in the first place?




  2. Martin
    Martin avatar
    1046 posts

    Posted 21 Apr Link to this post

    Hello Jen,

    The drop down is closed because there is an additional framework logic that applies for the IsDefault property based on the different focus scopes. In addition the drop down content of the split button is rendered in a Popup element which is placed in a different visual tree than the application. Currently, the Enter key executes the Click of the split part button of the RadSplitButton control because .

    In order to achieve your requirement you can focus an element in the drop down content of the split button when it is opened. For example, the text input or the button itself. 
    private void splitButton_DropDownOpened(object sender, RoutedEventArgs e)
        var content = this.splitButton.DropDownContent as FrameworkElement;
        var button = content.FindChildByType<Button>();

    I will also share the approach from your support ticket on the same topic, because it might be useful for someone that experiencing the same behavior.
    private void splt_Customer_PreviewKeyDown(object sender, KeyEventArgs e)
        if (e.Key == Key.Return || e.Key == Key.Enter)
            e.Handled = true;
            Model.Seach(); //button execute

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top