Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlipView SelectionChanged event firing twice since 2.4.0 #4012

Closed
GSDragoon opened this issue Dec 22, 2020 · 0 comments · Fixed by #4054
Closed

FlipView SelectionChanged event firing twice since 2.4.0 #4012

GSDragoon opened this issue Dec 22, 2020 · 0 comments · Fixed by #4054
Assignees
Labels
Milestone

Comments

@GSDragoon
Copy link

Describe the bug

Since MahApps.Metro 2.4.0, the FlipView SelectionChanged event is firing twice. 2.3.4 is only doing this once. I have a long running task in that event and this issue is causing problems.

Steps to reproduce

  1. Add a SelectionChanged event to a FlipView with multiple items.
  2. Set a break point on that SelectionChanged method.
  3. Navigate the FlipView views/items and notice 2.3.4 only hits that method once per navigation while 2.4.0 (up to the current latest 2.4.3) triggers the method twice.

Expected behavior

The SelectionChanged event should only fire once for FlipView.

Actual behavior

From what I can tell, 2.3.4 is firing the event just for the FlipView while changes in 2.4.0 make it so the event is also triggered for the underlying ListBox control. I was looking at the OriginalSource on the SelectionChangedEventArgs. I tried setting e.Handled = true in my event, but that didn't prevent it from triggering a second time.

Environment

MahApps.Metro version: v2.4.0
Windows build number: Win10 20H2 [OS Build: 19042.685]
Visual Studio: 2019 16.8.3
Target Framework: .NET Framework 4.8, .NET Core 3.1.10 and .NET 5.0.1 (Recreated with all three)

Screenshots

N/A

@GSDragoon GSDragoon added the Bug label Dec 22, 2020
@punker76 punker76 self-assigned this Dec 23, 2020
@punker76 punker76 modified the milestones: 2.5.0, 2.4.4 Dec 23, 2020
punker76 added a commit that referenced this issue Feb 27, 2021
The SelectionChanged event is a bubbling event, so if the ListBox inside the FlipView fires the event, all other events in the same container will be fired.
punker76 added a commit that referenced this issue Feb 27, 2021
Fix FlipView SelectionChanged event firing twice
batzen pushed a commit to batzen/MahApps.Metro that referenced this issue Mar 3, 2021
The SelectionChanged event is a bubbling event, so if the ListBox inside the FlipView fires the event, all other events in the same container will be fired.
batzen pushed a commit to batzen/MahApps.Metro that referenced this issue Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants