In an Mvvm
application, I have a page that has two methods that run in the ViewModel before the Xaml runs. They run in the wrong order, and I'm wondering if there's a way to tell it which method to run first.
The method that runs second is the implementation of the IConvertible
interface, used to pass an object from a previous page. I would like it to run first.
The method that runs first is Appearing()
, which is the MVVM answer to the OnAppearing
method. I would like it to run second.
// this method runs first, I would like it to run second
[RelayCommand]
private async Task Appearing()
{
// no access to VideoObj because this method runs before ApplyQueryAttributes
string x = VideoObj.ThumbnailFilename;
}
// this method runs second, I would like it to run first
public void ApplyQueryAttributes(IDictionary<string, object> query)
{
Package = query["Package"] as VideoPackage;
VideoObj = Package.video;
}
Is there a way in C# or Maui to order this kind of thing?
Why don't you trigger a method after both have been fired, so it is order agnostic? e.g.