Skip to content

Switch Animation breaks on NavigationPage changeΒ #15358

Open
@DarkIrata

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.

  1. 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.
  2. 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

  1. Create a new .MAUI App
  2. Modify the App.xaml.cs and change the MainPage value to MainPage = new NavigationPage(new MainPage());
  3. 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);
  4. Open the MainPage Code Behind
    4.1 In the ctor, initialize with new 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);
  5. Run the App within an Android Emulator
  6. Navigate to AnotherPage by clicking the Count Button and click on the switch, it should work fine.
  7. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions