I rewrite my old UWP application using the паттерна MVVM , the following problems have arisen:
1. Navigation.
In the previous version I just wrote to navigate between pages:
<Button Name="btSettings" Click="btSettings_Click"/> and in CodeBehind:
private void btSettings_Click(object sender, RoutedEventArgs e) { Frame.Navigate(typeof(SettingsPage)); } How to do it now? In the VM I will add the OpenSettings command, for example, and make a binding:
<AppBarButton Icon="Setting" Label="Настройки" Command="{Binding OpenSettings}"/> and what to write in the command method? Frame in VM is naturally unavailable
2. Binding the team to the event.
It is necessary to execute the command after the page loading, how to do it?
In a WPF application, I did something like this:
xmlns:intr="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" <intr:Interaction.Triggers> <intr:EventTrigger EventName="Loaded"> <intr:InvokeCommandAction Command="{Binding LoadData}"/> </intr:EventTrigger> </intr:Interaction.Triggers> here, as I understand it, this assembly is not available