File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
windows/ReactNativePicker Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 88
99#include < winrt/Windows.Foundation.Metadata.h>
1010#include < UI.Xaml.Input.h>
11+ #include < UI.Xaml.Media.h>
1112
1213namespace winrt {
1314 using namespace Microsoft ::ReactNative;
@@ -50,6 +51,20 @@ namespace winrt::ReactNativePicker::implementation {
5051 winrt::FocusManager::TryFocusAsync (comboBox, winrt::FocusState::Programmatic);
5152 }
5253 });
54+
55+ // Workaround XAML bug with ComboBox and dark theme. Same as:
56+ // https://github.com/microsoft/microsoft-ui-xaml/issues/2331
57+ m_dropDownOpenedRevoker = this ->DropDownOpened (winrt::auto_revoke,
58+ [](auto const & sender, auto const & /* args*/ ) {
59+ auto comboBox = sender.as <xaml::Controls::ComboBox>();
60+ if (comboBox.XamlRoot ()) { // XamlRoot added in 19H1
61+ auto comboBoxAsFrameworkElement = comboBox.XamlRoot ().Content ().try_as <xaml::FrameworkElement>();
62+ auto popups = xaml::Media::VisualTreeHelper::GetOpenPopupsForXamlRoot (comboBox.XamlRoot ());
63+ for (auto const & popup : popups) {
64+ popup.Child ().as <xaml::FrameworkElement>().RequestedTheme (comboBoxAsFrameworkElement.ActualTheme ());
65+ }
66+ }
67+ });
5368 }
5469
5570 void ReactPickerView::UpdateProperties (winrt::IJSValueReader const & reader) {
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ namespace winrt::ReactNativePicker::implementation {
2525 xaml::Media::Brush m_comboBoxColor{ nullptr };
2626 xaml::Controls::ComboBox::SelectionChanged_revoker m_selectionChangedRevoker{};
2727 xaml::Controls::ComboBox::DropDownClosed_revoker m_dropDownClosedRevoker{};
28+ xaml::Controls::ComboBox::DropDownOpened_revoker m_dropDownOpenedRevoker{};
2829
2930 void RegisterEvents ();
3031 void RepopulateItems (winrt::Microsoft::ReactNative::JSValueArray const & items);
You can’t perform that action at this time.
0 commit comments