I have been following the Prism 7.2.0.1367 release notes. I am able to navigate to a dialog ViewModel using dialogService.ShowDialog(NavigationStrings.MyViewModel)
. But when I close it, I get a null reference exception on RequestClose.
I have a ViewModel like so in my Xamarin Forms project:
public class MyViewModel : BaseViewModel, IDialogAware, IAutoInitialize
{
private DelegateCommand _closeCommand;
public DelegateCommand CloseCommand => _closeCommand ?? (_closeCommand = new DelegateCommand(Close));
public event Action<IDialogParameters> RequestClose;
public MyViewModel(INavigationService navigationService) : base(navigationService) { }
public override void OnAppearing()
{
base.OnAppearing();
}
private void Close()
{
RequestClose(null);
}
public bool CanCloseDialog() => true;
public void OnDialogClosed()
{
Console.WriteLine("The Demo Dialog has been closed...");
}
public void OnDialogOpened(IDialogParameters parameters)
{
// No need to do anything as IAutoInitialize will take care of what we need here...
}
}
What am I supposed to set RequestClose to to stop it from being null? None of the documentation says anything about having to set this event.