Bound ComboBox within a page and frame not working as expected - WinUI 3
Hi,
i have a bound ComboBox which i've already posted here.
I'm adding a separator by a TemplateSelector but to disable the separator, I have to iterate the ComboBoxItems in the Tapped event and set the IsEnabled property to false. This has to be happened in the Tapped event because this is the only event where the items are already rendered, I guess.
This is in MainWindow.xaml and is working great.
Now I have the exact same code on another page (SelectFunction.xaml) which is opened by a frame in MainWindow.xaml but the Tapped event is not working as expected like in MainWindow.xaml. The event gets only sporadically fired, mostly only, if you click near the area of the arrow. It's weird. I've tried a few things from posts where people had similar problems:
- setting a background on the Frame/ ComboBox
- setting the isHitTestVisible property
- isSynchronizeWithCurrentItem (this throws an error when opening the ComboBox)
Further, even if i can disable iterate the items i can't get the item as before with ItemContainerGenerator because i get an Access Violation and the item is null even, if I can get the values by casting.
I've tried to change the ComboBox Access by using the name, casting the sender, getting it by a static instance of the page (winrt::App1::implementation::SelectFunction* SelectFunction::s_selectFunction;)
I've added the items from code behind at first because and it's only text that i would need no template. It works great but it's not that practical, so i changed to binding.
From code behind like so but really ugly, if i have 30 items and it's dynamically changing:
winrt::Microsoft::UI::Xaml::Controls::ComboBoxItem cmbi0;
cmbi0.Name(L"cmbiNoAction");
cmbi0.Content(winrt::box_value(L"Keine Aktion"));
cmbFunction().Items().Append(winrt::box_value(cmbi0));
winrt::Microsoft::UI::Xaml::Controls::NavigationViewItemSeparator separator1;
winrt::Microsoft::UI::Xaml::Controls::ComboBoxItem cmbiA;
cmbiA.IsEnabled(false);
cmbiA.Content(winrt::box_value(separator1));
cmbFunction().Items().Append(winrt::box_value(cmbiA));
winrt::Microsoft::UI::Xaml::Controls::ComboBoxItem cmbi1;
cmbi1.Content(winrt::box_value(L"Category1"));
cmbi1.IsEnabled(false);
cmbFunction().Items().Append(winrt::box_value(cmbi1));
It looks like a WinUi 3 bug to me, what are you thinking?