Hello,
Welcome to our Microsoft Q&A platform!
You could also use Delegate to achieve the function. Create the delegate in the TabbedPage's ViewModel class and then subscribe the event in child page's ViewModel class.
//the viewModel class of the tabbedPage
public delegate void TestEventHandler();
namespace TestApplication
{
public class ViewModel_TabbedPge
{
public event TestEventHandler TestEvent;
public async Task TestMethod()
{
var response = await getResponseMethod();
if (TestEvent != null)
{
TestEvent();
}
}
}
}
//the child page
public class ViewModel_Page1
{
ViewModel_Page1 viewModel;
ViewModel_TabbedPge viewModel_TabbedPge;
public ViewModel_Page1(ViewModel_TabbedPge viewModel_TabbedPge)
{
InitializeComponent();
viewModel = new ViewModel_Page1();
BindingContext = viewModel;
viewModel_TabbedPge = App.viewModel_TabbedPge;//create a global static instance of the ViewModel_TabbedPge class in the App.cs
viewModel_TabbedPge.TestEvent += TheTestEvent;
}
private void TheTestEvent()
{
//perform the work
}
}
Best Regards,
Jarvan Zhang
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.