michalt38
michalt38

Reputation: 1203

Check if combobox is opened

How can I check if the combobox's dropdown list is opened? (https://learn.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.ComboBox?view=winrt-19041)

Upvotes: 0

Views: 981

Answers (2)

Faywang - MSFT
Faywang - MSFT

Reputation: 5868

You can subscribe the DropDownOpened event which will be triggered when you try to open the dropdown list or use IsDropDownOpen property to judge whether the drop-down portion of the ComboBox is currently open.

.xaml:

<ComboBox x:Name="MyComboBox" DropDownOpened="MyComboBox_DropDownOpened">
    <ComboBoxItem>123</ComboBoxItem>
</ComboBox>

.cpp:

void AppCX::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
    bool isOpen = MyComboBox->IsDropDownOpen;
}


void AppCX::MainPage::MyComboBox_DropDownOpened(Platform::Object^ sender, Platform::Object^ e)
{

}

Upvotes: 1

Vincent
Vincent

Reputation: 3304

You can use IsDropDownOpen property.

Definition

Gets or sets a value that indicates whether the drop-down portion of the ComboBox is currently open.

Upvotes: 1

Related Questions