microsoft / microsoft/microsoft-ui-xaml

FlipView can unload an element multiple times

Open
#11,800 0 comments 0 reactions 0 assignees View on GitHub
area-Lists bug team-Controls
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Flipping quickly in a FlipView causes some elements to be unloaded twice.

### Why is this important?

Incorrect processing makes it hard to program the FlipView.

### Steps to reproduce the bug

Download and compile the WinUI Gallery. Add the following at the bottom of the StackPanel on the FlipView page:

```









```

Add the following in the code-behind:
```
private void TextBlock_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
Debug.WriteLine($"Loaded {((TextBlock)sender).Text}");
}

private void TextBlock_Unloaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
Debug.WriteLine($"Unloaded {((TextBlock)sender).Text}");
}
```

Run the program in debug mode and go to the new control at the bottom of the FlipView page. Click the right-arrow button in a normal way to get to item Four. Then triple-click the back button (rapidly click the back button three times). Observe "Unloaded Four" occurring twice in a row near the end of the output:

```
Loaded One
Loaded Two
Loaded Three
Loaded Four
Unloaded Four
Loaded Four
Loaded One
Unloaded One
Unloaded One
Unloaded Two
Loaded Two
Loaded Four
Loaded One
Unloaded Four
Unloaded Four
Loaded Four
```

### Actual behavior

FlipView can sometimes unload items twice.

### Expected behavior

FlipView should only unload items once.

### Screenshots

n/a

### NuGet package version

WinUI Gallery 2.10.0.0, .NET 9, Windows App SDK 2.4

### Windows version

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue in the WinUI Gallery using the added FlipView and Loaded/Unloaded handlers, then trace the FlipView implementation and its item unload processing. Use the debug output to confirm the rapid back-button sequence; done when each item emits Unloaded only once.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.