问题
How to make first row of combobox not-selectable? (https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.ComboBox?view=winrt-19041)
回答1:
Combox first row not selectable
You could detect DropDownOpened
event and find the fist item with ContainerFromIndex
then disable it like the following. Because Combobox dropdown is lazy load, so we need add the task delay in DropDownOpened
event.
private async void MyCb_DropDownOpened(object sender, object e)
{
await Task.Delay(100);
var item = MyCb.ContainerFromIndex(0) as ComboBoxItem;
if (item != null)
{
item.IsEnabled = false;
}
}
来源:https://stackoverflow.com/questions/62533192/combox-first-row-not-selectable