Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Frame.GoBack(NavigationTransitionInfo) callback

Tags:

c#

.net

uwp

I want to scroll down to bottom of a GridView when navigating back from another page.To be more specific exactly when Frame.GoBack(NavigationTransitionInfo) ends, so the scrolling would be visible. There is a callback or some way to notify when the transition ended?

like image 718
Madalina Avatar asked Feb 12 '26 06:02

Madalina


1 Answers

I was wondering if GoBack() has a callback or notifies when the page transition ended

GoBack has no call back, so you can't detect transition ended with GoBack method. For your requirement, You could make custom callback method with Action.

Page1

public sealed partial class BlankPage1 : Page
{
    public BlankPage1()
    {
        this.InitializeComponent();
    }
    private static Action _callBackAction;
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        Frame.GoBack();
        Task.Delay(TimeSpan.FromSeconds(1)).ContinueWith((task)=> {

            _callBackAction();
        });       
    }
    public static void CallBackMethod( Action action)
    {
        _callBackAction = action;

    }
}

Page0

public Page0()
{
    this.InitializeComponent();
    BlankPage1.CallBackMethod(() =>
    {
        //do some stuff

    });    
}
like image 177
Nico Zhu - MSFT Avatar answered Feb 14 '26 20:02

Nico Zhu - MSFT