For Info I have resolved this. It was a case of insufficient knowledge!
More detail. Previously I had used FreshMVVM for Xamarin, but I switched to the Community.Toolkit.MVVM for the conversion. I needed to update the ViewModel's List selection mode before displaying the main page.
Using XF I used protected override void ViewIsAppearing in the ViewModel to detect the ViewIsAppearing Event. So I tried using the .Net Maui OnAppearing in the MainViewModel. It wasn't recognised! But I noted that I could use OnAppearing in the MainPage XAML code behind page.
However (see image attached) I wasn't picking up the ViewModel reference in the OnAppearing Function. So I had to reference the ViewModel in that function. This is quite an ugly solution, as code I would have liked in the ViewModel is now in the code behind page. With FreshMVVM I never put any extra code in the XAML code behind which was neater. I appreciate FreshMVVM is available for MAUI but I will press on with Community.Toolkit.MVVM.
After all this, the upload docs wouldnt work. So I have included a snippet below. Hope this helps some other MAUI newbie!
public partial class MainPage : ContentPage
{
public MainPage(MainViewModel vm)
{
// This approach is in keeping with the CommunityToolkit.ComponentModel
InitializeComponent();
BindingContext = vm
}
//My mental block was that this was previously in the ViewModel for Xamarin
override protected void OnAppearing()
{
Base.OnAppearing();
var vm = BindingContext as MainViewModel; //Note the binding context here was essential.
vm.DummyData = “Yeh! OnAppearing Worked Correctly!”;
}
}