Skip to content

Commit

Permalink
Add RaisePropertyChanged call to ToggleSplitButton (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
jevansaks authored Apr 26, 2019
1 parent 8a3b96c commit d4a0f00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dev/SplitButton/InteractionTests/SplitButtonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions dev/SplitButton/ToggleSplitButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ void ToggleSplitButton::OnIsCheckedChanged()
{
auto eventArgs = winrt::make_self<ToggleSplitButtonIsCheckedChangedEventArgs>();
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();
Expand Down

0 comments on commit d4a0f00

Please sign in to comment.