Skip to content

Commit a36d84c

Browse files
committed
winUI2 CBF
1 parent 6e90171 commit a36d84c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ struct CustomAppBarButton : xaml::Controls::AppBarButtonT<CustomAppBarButton> {
3030
}
3131
};
3232

33-
void FixProofingMenuCrashForXamlIsland(xaml::Controls::TextCommandBarFlyout const &flyout) {
33+
void FixProofingMenuCrashForXamlIsland(xaml::Controls::Primitives::FlyoutBase const &flyout) {
3434
flyout.Opening([](winrt::IInspectable const &sender, auto &&) {
35+
#ifdef USE_WINUI2_CBF
36+
const auto &flyout = sender.as<winrt::Microsoft::UI::Xaml::Controls::TextCommandBarFlyout>();
37+
#else
3538
const auto &flyout = sender.as<xaml::Controls::TextCommandBarFlyout>();
39+
#endif
3640
if (const auto &textBox = flyout.Target().try_as<xaml::Controls::TextBox>()) {
3741
const auto &commands = flyout.SecondaryCommands();
3842
for (uint32_t i = 0; i < commands.Size(); ++i) {

vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77

88
#include <UI.Xaml.Controls.Primitives.h>
99
#include <UI.Xaml.Controls.h>
10+
#define USE_WINUI2_CBF
11+
#ifdef USE_WINUI2_CBF
12+
#include <winrt/Microsoft.UI.Xaml.Controls.h>
13+
#endif
1014

1115
namespace Microsoft::ReactNative {
1216

13-
void FixProofingMenuCrashForXamlIsland(xaml::Controls::TextCommandBarFlyout const &flyout);
17+
void FixProofingMenuCrashForXamlIsland(xaml::Controls::Primitives::FlyoutBase const &flyout);
1418

1519
template <typename T>
1620
inline void EnsureUniqueTextFlyoutForXamlIsland(T const &textView) {
@@ -19,7 +23,12 @@ inline void EnsureUniqueTextFlyoutForXamlIsland(T const &textView) {
1923
// to show the flyout on other windows cause the first window to get focus.
2024
// https://github.com/microsoft/microsoft-ui-xaml/issues/5341
2125
if (IsXamlIsland()) {
26+
#ifdef USE_WINUI2_CBF
27+
winrt::Microsoft::UI::Xaml::Controls::TextCommandBarFlyout flyout;
28+
#else
2229
xaml::Controls::TextCommandBarFlyout flyout;
30+
#endif
31+
2332
flyout.Placement(xaml::Controls::Primitives::FlyoutPlacementMode::BottomEdgeAlignedLeft);
2433

2534
// This works around a XAML Islands bug where the Proofing sub-menu for

0 commit comments

Comments
 (0)