locked
Flipview doesn't maintain selectedindex after returning from mail app via lancher. RRS feed

  • Question

  • I am facing an issue with FlipView. I am sharing the minimalistic project, which represent my usecase in original app, http://1drv.ms/163kHCR.

    I have two pages. First is MainPage.xaml. It has a flipview with five times. First four has just textblock and fifth one has one button. Clicking on it I will be redirected to Next.xaml. Please note MainPage has NavigationCacheMode as NavigationCacheMode.Required [Which is required for my original app]. So last known index of FlipView is 4.

    In Next page there's a button clicking on it, opens the mail client via launcher. Now when I press back from mail client I would be navigated to Next page and pressing back one more time, I will be on MainPage and selected index will be 4, that's correct. Now when I swipe to right to see FlipViewItem with index 3, it immediately show me first FlipViewItem with index 0. It just skips all the items till index 0.

    I request MSDN to check the issue. Is there anything wrong in the code?

    MainPage.Xaml

    <Grid Grid.Row="1" x:Name="ContentRoot">
        <FlipView x:Name="fv">
            <FlipViewItem>
                <TextBlock Text="1" FontSize="50" />
            </FlipViewItem>
            <FlipViewItem>
                <TextBlock Text="2" FontSize="50" />
            </FlipViewItem>
            <FlipViewItem>
                <TextBlock Text="3" FontSize="50" />
            </FlipViewItem>
            <FlipViewItem>
                <TextBlock Text="4" FontSize="50" />
            </FlipViewItem>
            <FlipViewItem>
                <Button Content="Next" Click="btnNext_Click" />
            </FlipViewItem>
        </FlipView>
    </Grid>
    


    MainPage.Xaml.cs

    public MainPage()
    {
        this.InitializeComponent();

        this.navigationHelper = new NavigationHelper(this);
        this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
        this.navigationHelper.SaveState += this.NavigationHelper_SaveState;

        NavigationCacheMode = NavigationCacheMode.Required;
    }
    private void btnNext_Click(object sender, RoutedEventArgs e) { Frame.Navigate(typeof(Next)); }

    Next.xaml (NavigationCacheMode is not set)

    <Grid Grid.Row="1" x:Name="ContentRoot">
        <Button Content="Mail" Click="btnMail_Click" />
    </Grid>
    
    Next.xaml.cs
    private async void btnMail_Click(object sender, RoutedEventArgs e)
    {
        var mailto = "mailto:?to=windows@microsoft.com&subject=Email&body=body";
        await Windows.System.Launcher.LaunchUriAsync(new Uri(mailto));
    }
    

    Friday, January 30, 2015 9:37 AM

Answers

  • Got solution from Stack Overflow. Calling InvalidateScrollInfo() on the ScrollViewer in the FlipView's template resolves the issue.
    • Marked as answer by Xyroid Monday, February 16, 2015 6:33 AM
    Monday, February 16, 2015 6:33 AM