检查组合框是否打开

Check if combobox is opened

如何检查组合框下拉列表是否打开? (https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.ComboBox?view=winrt-19041)

您可以使用 IsDropDownOpen 属性.

Definition

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

您可以订阅DropDownOpened event which will be triggered when you try to open the dropdown list or use IsDropDownOpen 属性判断ComboBox的下拉部分当前是否打开

.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)
{

}