Switch Animation breaks on NavigationPage changeΒ #15358
Open
Description
Description
The Switch Control switching animation works the first, but not the second time. It will instantly flip to the other side when clicken it.
For this to happen, some conditions need to be met.
- Page with Switch Control needs to be replaced with the parent NavigationPage. This can also happen when using the same NavigationPage, but then its more complex to reproduce.
- The Page with the Switch Control needs to be reused. Be it a singleton, static, etc
Steps to Reproduce
This would be the bare minimum for reproduction
- Create a new .MAUI App
- Modify the App.xaml.cs and change the MainPage value to
MainPage = new NavigationPage(new MainPage());
- Add another Content Page 'AnotherPage.xaml'
3.1 Add to this Page a Switch Control<Switch />
3.2 Add a Button<Button x:Name="NavigateBtn" Clicked="NavigateBtn_Clicked" Text="Back" />
3.3 [Code Behind] Add MainPage as a parameter to the ctor and save it in a field variable called "mp"
3.4 [Code Behind] Add the NavigateBtn_Clicked Method and set the content to
Application.Current.MainPage = new NavigationPage(mp);
- Open the MainPage Code Behind
4.1 In the ctor, initialize withnew AnotherPage(this)
and save it in a field variable called "ap"
4.2 Modify the Count Button to do the following
Application.Current.MainPage = new NavigationPage(ap);
- Run the App within an Android Emulator
- Navigate to AnotherPage by clicking the Count Button and click on the switch, it should work fine.
- Click the Back Button and then again the Count Button. The switch animation should now be broken.
Link to public reproduction project repository
https://github.com/DarkIrata/Maui-Switch-Animation-Bug
Version with bug
7.0.86
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13
Did you find any workaround?
No response
Relevant log output
No response
Activity