Xamarin Shell page appearing or navigated to event ?

StephenH 86 Reputation points
2021-03-17T00:05:38.52+00:00

I may be missing it but when I navigate back to a page from say a detail edit page using Xamarin Shell how do I know I need to refresh the data ? Is there an event somewhere that I can override to use as a "refresh" when the page is being navigated to ? Thanks for any and all help or suggestions !

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-17T03:06:08.353+00:00

    Hello,

    Welcome to Microsoft Q&A!

    You could refresh the data in OnAppearing method or Shell.Current.Navigated event .

    OnAppearing

       protected override void OnAppearing()  
         {  
             base.OnAppearing();  
         
             //refresh the data  
         }  
    

    Shell.Current.Navigated

       public YourPage()  
         {  
             InitializeComponent();  
         
             Shell.Current.Navigated += (sender,e) => {   
                 if(e.Source == ShellNavigationSource.Pop)  
                 {  
                       //refresh the data  
                 }  
             };  
         }  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.