I'm building a UWP application with PCL using prism.
PCL contains the ViewModels
UWP contains the Views
My problem is I cannot use INavigationService in the PCL so I can't really navigate to other pages.
Here is my code:
MainPage.xaml (in UWP project):
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<SplitView x:Name="RootSplitView"
DisplayMode="Overlay"
IsTabStop="False">
<SplitView.Pane>
<StackPanel Margin="0,50,0,0">
<Button Content="Second" Command="{x:Bind ViewModel.SecondPageCommand}" />
<Button Content="Third" />
</StackPanel>
</SplitView.Pane>
<!-- OnNavigatingToPage we synchronize the selected item in the nav menu with the current page.
OnNavigatedToPage we move keyboard focus to the first item on the page after it's loaded and update the Back button. -->
<Frame x:Name="FrameContent" />
</SplitView>
<ToggleButton x:Name="TogglePaneButton"
TabIndex="1"
IsChecked="{Binding IsPaneOpen, ElementName=RootSplitView, Mode=TwoWay}"
ToolTipService.ToolTip="Menu"
Style="{StaticResource SplitViewTogglePaneButtonStyle}"
/>
</Grid>
ViewModel (in the PCL):
public class NavigationRootViewModel : BindableBase
{
public ICommand SecondPageCommand { get; set; }
public NavigationRootViewModel()
{
SecondPageCommand = DelegateCommand.FromAsyncHandler(ExecuteMethod);
}
private Task ExecuteMethod()
{
return Task.FromResult(0);
}
}
My wish was to inject INavigationService in the constructor but it's not part of the Prism.Core dll.
So what is the correct way to do it? Is it even possible to navigate in PCL using Prism ? in MvvmCross it is...