Combox first row not selectable

时间秒杀一切 提交于 2021-01-28 09:00:19

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!