首页 > 解决方案 > 检查组合框是否打开

问题描述

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

标签: c++uwpc++-cx

解决方案


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

}

推荐阅读