I am using Nuget CommunityToolkit.Maui.Views. I my Maui application I also using viewModels. Now I would like to show my custom dialog from viewmodel method. But
this.ShowPopup(new DialogPopup());
Can by invoke only on Page object.
I can assign value Page to property in my viewModel, but I am not sure this is the best option to implement it:
private readonly MainViewModel _mainViewModel;
public MainPage(MainViewModel vm)
{
InitializeComponent();
BindingContext = vm;
_mainViewModel = vm;
_mainViewModel.Page = this;
}
and in view model
public Page Page { get; set; }
and
Page.ShowPopup(new DialogPopup());
ShowPopup method look like this:
public static void ShowPopup<TPopup>(this Page page, TPopup popup) where TPopup : Popup {...}
How should I implement it to be able use this ShowPupup method in my view model?
I am using Net 7.0 and dependency injection to initialize my object.