diff --git a/dev/Generated/RadioMenuFlyoutItem.properties.cpp b/dev/Generated/RadioMenuFlyoutItem.properties.cpp index e751cf3aa6..5e40c21b8c 100644 --- a/dev/Generated/RadioMenuFlyoutItem.properties.cpp +++ b/dev/Generated/RadioMenuFlyoutItem.properties.cpp @@ -13,6 +13,7 @@ namespace winrt::Microsoft::UI::Xaml::Controls #include "RadioMenuFlyoutItem.g.cpp" +GlobalDependencyProperty RadioMenuFlyoutItemProperties::s_AreCheckStatesEnabledProperty{ nullptr }; GlobalDependencyProperty RadioMenuFlyoutItemProperties::s_GroupNameProperty{ nullptr }; GlobalDependencyProperty RadioMenuFlyoutItemProperties::s_IsCheckedProperty{ nullptr }; @@ -23,6 +24,17 @@ RadioMenuFlyoutItemProperties::RadioMenuFlyoutItemProperties() void RadioMenuFlyoutItemProperties::EnsureProperties() { + if (!s_AreCheckStatesEnabledProperty) + { + s_AreCheckStatesEnabledProperty = + InitializeDependencyProperty( + L"AreCheckStatesEnabled", + winrt::name_of(), + winrt::name_of(), + true /* isAttached */, + ValueHelper::BoxValueIfNecessary(false), + &RadioMenuFlyoutItem::OnAreCheckStatesEnabledPropertyChanged); + } if (!s_GroupNameProperty) { s_GroupNameProperty = @@ -49,6 +61,7 @@ void RadioMenuFlyoutItemProperties::EnsureProperties() void RadioMenuFlyoutItemProperties::ClearProperties() { + s_AreCheckStatesEnabledProperty = nullptr; s_GroupNameProperty = nullptr; s_IsCheckedProperty = nullptr; } @@ -69,6 +82,17 @@ void RadioMenuFlyoutItemProperties::OnIsCheckedPropertyChanged( winrt::get_self(owner)->OnPropertyChanged(args); } + +void RadioMenuFlyoutItemProperties::SetAreCheckStatesEnabled(winrt::MenuFlyoutSubItem const& target, bool value) +{ + target.SetValue(s_AreCheckStatesEnabledProperty, ValueHelper::BoxValueIfNecessary(value)); +} + +bool RadioMenuFlyoutItemProperties::GetAreCheckStatesEnabled(winrt::MenuFlyoutSubItem const& target) +{ + return ValueHelper::CastOrUnbox(target.GetValue(s_AreCheckStatesEnabledProperty)); +} + void RadioMenuFlyoutItemProperties::GroupName(winrt::hstring const& value) { [[gsl::suppress(con)]] diff --git a/dev/Generated/RadioMenuFlyoutItem.properties.h b/dev/Generated/RadioMenuFlyoutItem.properties.h index 698362df5f..0aa21db34a 100644 --- a/dev/Generated/RadioMenuFlyoutItem.properties.h +++ b/dev/Generated/RadioMenuFlyoutItem.properties.h @@ -9,15 +9,20 @@ class RadioMenuFlyoutItemProperties public: RadioMenuFlyoutItemProperties(); + static void SetAreCheckStatesEnabled(winrt::MenuFlyoutSubItem const& target, bool value); + static bool GetAreCheckStatesEnabled(winrt::MenuFlyoutSubItem const& target); + void GroupName(winrt::hstring const& value); winrt::hstring GroupName(); void IsChecked(bool value); bool IsChecked(); + static winrt::DependencyProperty AreCheckStatesEnabledProperty() { return s_AreCheckStatesEnabledProperty; } static winrt::DependencyProperty GroupNameProperty() { return s_GroupNameProperty; } static winrt::DependencyProperty IsCheckedProperty() { return s_IsCheckedProperty; } + static GlobalDependencyProperty s_AreCheckStatesEnabledProperty; static GlobalDependencyProperty s_GroupNameProperty; static GlobalDependencyProperty s_IsCheckedProperty; diff --git a/dev/RadioMenuFlyoutItem/InteractionTests/RadioMenuFlyoutItemTests.cs b/dev/RadioMenuFlyoutItem/InteractionTests/RadioMenuFlyoutItemTests.cs index 567d3403c3..6078515feb 100644 --- a/dev/RadioMenuFlyoutItem/InteractionTests/RadioMenuFlyoutItemTests.cs +++ b/dev/RadioMenuFlyoutItem/InteractionTests/RadioMenuFlyoutItemTests.cs @@ -56,46 +56,88 @@ public void TestCleanup() }; [TestMethod] - [TestProperty("Ignore", "True")] // Disabled as per tracking issue #3125 and internal issue 19603059 public void BasicTest() { + if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone3)) + { + Log.Warning("Test is disabled on RS2"); + return; + } + using (var setup = new TestSetupHelper("RadioMenuFlyoutItem Tests")) { Log.Comment("Verify initial states"); - VerifySelectedItems("Orange", "Compact"); + VerifySelectedItems("Orange", "Compact", "Name"); - InvokeItem("Yellow"); - VerifySelectedItems("Yellow", "Compact"); + InvokeItem("FlyoutButton", "YellowItem"); + VerifySelectedItems("Yellow", "Compact", "Name"); - InvokeItem("Expanded"); - VerifySelectedItems("Yellow", "Expanded"); + InvokeItem("FlyoutButton", "ExpandedItem"); + VerifySelectedItems("Yellow", "Expanded", "Name"); Log.Comment("Verify you can't uncheck an item"); - InvokeItem("Yellow"); - VerifySelectedItems("Yellow", "Expanded"); + InvokeItem("FlyoutButton", "YellowItem"); + VerifySelectedItems("Yellow", "Expanded", "Name"); } } - public void InvokeItem(string item) + [TestMethod] + public void SubMenuTest() { - Log.Comment("Open flyout"); - Button flyoutButton = FindElement.ByName + + + + + - - - - + diff --git a/dev/RadioMenuFlyoutItem/TestUI/RadioMenuFlyoutItemPage.xaml.cs b/dev/RadioMenuFlyoutItem/TestUI/RadioMenuFlyoutItemPage.xaml.cs index e753183ebd..0f34a2dd46 100644 --- a/dev/RadioMenuFlyoutItem/TestUI/RadioMenuFlyoutItemPage.xaml.cs +++ b/dev/RadioMenuFlyoutItem/TestUI/RadioMenuFlyoutItemPage.xaml.cs @@ -44,23 +44,36 @@ public RadioMenuFlyoutItemPage() // register all RadioMenuFlyoutItems foreach (MenuFlyoutItemBase item in ButtonMenuFlyout.Items) { - if (item is RadioMenuFlyoutItem) - { - RadioMenuFlyoutItem radioItem = item as RadioMenuFlyoutItem; + RegisterItem(item); + } + foreach(MenuFlyoutItemBase item in ButtonSubMenuFlyout.Items) + { + RegisterItem(item); + } + foreach (MenuFlyoutItemBase item in RadioSubMenu.Items) + { + RegisterItem(item); + } + } - radioItem.RegisterPropertyChangedCallback(RadioMenuFlyoutItem.IsCheckedProperty, new DependencyPropertyChangedCallback(IsCheckedChanged)); + private void RegisterItem(MenuFlyoutItemBase item) + { + if (item is RadioMenuFlyoutItem) + { + RadioMenuFlyoutItem radioItem = item as RadioMenuFlyoutItem; - TextBlock nameText = new TextBlock(); - nameText.Text = radioItem.Text; - ItemNames.Children.Add(nameText); + radioItem.RegisterPropertyChangedCallback(RadioMenuFlyoutItem.IsCheckedProperty, new DependencyPropertyChangedCallback(IsCheckedChanged)); - TextBlock stateText = new TextBlock(); - AutomationProperties.SetName(stateText, radioItem.Text + "State"); - UpdateTextState(radioItem, stateText); - ItemStates.Children.Add(stateText); + TextBlock nameText = new TextBlock(); + nameText.Text = radioItem.Text; + ItemNames.Children.Add(nameText); + + TextBlock stateText = new TextBlock(); + AutomationProperties.SetName(stateText, radioItem.Text + "State"); + UpdateTextState(radioItem, stateText); + ItemStates.Children.Add(stateText); - itemStates.Add(radioItem.Text, stateText); - } + itemStates.Add(radioItem.Text, stateText); } }