Dropdownbutton dropdowncontent wont close

1 Answer 63 Views
Buttons
Tony
Top achievements
Rank 1
Tony asked on 20 Nov 2022, 08:22 PM | edited on 20 Nov 2022, 08:25 PM

Hi,

I am having a problem where I am using a dropdownbutton with some custom controls inside the dropdowncontent area.

Whenever I click an item, the dropdowncontent stays open.  I have tried setting "IsOpen" to false but it is having no effect.

Here is my code, xaml

<telerik:RadDropDownButton x:Name="_toolsDDB" AutoOpenDelay="0:0:0.0" DropDownButtonPosition="Right" Grid.Row="1"
                       IsBackgroundVisible="False" PopupAnimation="Fade" KeepOpen="False"
                        DropDownIndicatorVisibility="Collapsed" IsOpen="{Binding ToolsIsOpen, Mode=TwoWay}"
                         telerik:RadToolTipService.Placement="Top" Margin="5" DropDownPlacement="Right"
                         telerik:RadToolTipService.ToolTipContent="{Binding GlobalStrings.ToolsStr}">

Viewmodel

        public void FunctionClickedCommandHandler(object obj)
        {
            if (_selectedFunction != null)
            {
                _selectedFunction.Command.Execute(null);

                MouseButtonEventArgs args = obj as MouseButtonEventArgs;
                if (obj != null)
                {
                    RadListBox lb = args.Source as RadListBox;
                    if (lb != null)
                        lb.SelectedIndex = -1;

                }

                ToolsIsOpen = false;
            }
        }

I tried binding to "IsOpen" because for some items clicked I need the dropdown to stay open for others I need it to close as soon as an item is clicked.  Right now, I'm just trying to get it to close with the code above.

Here is a quick video showing whats happening

  Video

Thanks for any help.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 21 Nov 2022, 11:12 AM

Hello Tony,

The behavior that you are observing is the default one, however, you could achieve the desired result by setting the CloseOnPopupMouseLeftButtonUp property to True of the RadDropDownButton element. This way, once an item from the drop-down menu is selected, the popup will close.

<telerik:RadDropDownButton CloseOnPopupMouseLeftButtonUp="True"/>

The produced result is as follows:

Could you give this suggestion a try?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tony
Top achievements
Rank 1
commented on 21 Nov 2022, 05:10 PM

Hi Stenly,

I have already tried using "CloseOnPopupMouseLeftButtonUp" and I had the same result as I had shown in my video.

The dropdown isnt a menu, Im using a grid of listbox's to hold my controls.  In all the forum posts I could find your support team always said to use "IsOpen".  The binding does update when I put a break point in my viewmodel, but as I showed in my video, the dropdown stays visible.

Stenly
Telerik team
commented on 23 Nov 2022, 12:27 PM

Hello Tony,

In order for the drop-down to close, the Mode for the Binding instance of IsOpen would have to be set to TwoWay and the bound property would have to raise the property changed event. This way, once a button from the drop-down menu is clicked, setting the bound property to false will close the menu.

I have attached a sample project for you to test.

Tags
Buttons
Asked by
Tony
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or