From d4a0f008d899c0dbc0585e3255d701d196b828ff Mon Sep 17 00:00:00 2001 From: Jevan Saks Date: Fri, 26 Apr 2019 15:58:20 -0700 Subject: [PATCH] Add RaisePropertyChanged call to ToggleSplitButton (#615) --- dev/SplitButton/InteractionTests/SplitButtonTests.cs | 6 +++++- dev/SplitButton/ToggleSplitButton.cpp | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dev/SplitButton/InteractionTests/SplitButtonTests.cs b/dev/SplitButton/InteractionTests/SplitButtonTests.cs index d9fb381844..708bd04ae7 100644 --- a/dev/SplitButton/InteractionTests/SplitButtonTests.cs +++ b/dev/SplitButton/InteractionTests/SplitButtonTests.cs @@ -227,7 +227,11 @@ public void ToggleTest() Verify.AreEqual("Unchecked", toggleStateOnClickTextBlock.DocumentText); Log.Comment("Click primary button to check button"); - ClickPrimaryButton(splitButton); + using (var toggleStateWaiter = new PropertyChangedEventWaiter(splitButton, Scope.Element, UIProperty.Get("Toggle.ToggleState"))) + { + ClickPrimaryButton(splitButton); + Verify.IsTrue(toggleStateWaiter.TryWait(TimeSpan.FromSeconds(1)), "Waiting for the Toggle.ToggleState event should succeed"); + } Verify.AreEqual("Checked", toggleStateTextBlock.DocumentText); Verify.AreEqual("Checked", toggleStateOnClickTextBlock.DocumentText); diff --git a/dev/SplitButton/ToggleSplitButton.cpp b/dev/SplitButton/ToggleSplitButton.cpp index 0a42d7037e..4d11016a25 100644 --- a/dev/SplitButton/ToggleSplitButton.cpp +++ b/dev/SplitButton/ToggleSplitButton.cpp @@ -42,6 +42,13 @@ void ToggleSplitButton::OnIsCheckedChanged() { auto eventArgs = winrt::make_self(); m_isCheckedChangedEventSource(*this, *eventArgs); + + if (auto peer = winrt::FrameworkElementAutomationPeer::FromElement(*this)) + { + auto newValue = IsChecked() ? winrt::ToggleState::On : winrt::ToggleState::Off; + auto oldValue = (newValue == winrt::ToggleState::On) ? winrt::ToggleState::Off : winrt::ToggleState::On; + peer.RaisePropertyChangedEvent(winrt::TogglePatternIdentifiers::ToggleStateProperty(), box_value(oldValue), box_value(newValue)); + } } UpdateVisualStates();