【发布时间】:2016-09-03 13:04:55
【问题描述】:
我正在使用 prism 使用 PCL 构建 UWP 应用程序。
PCL 包含 ViewModels
UWP 包含视图
我的问题是我无法在 PCL 中使用 INavigationService,因此我无法真正导航到其他页面。
这是我的代码:
MainPage.xaml(在 UWP 项目中):
<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(在 PCL 中):
public class NavigationRootViewModel : BindableBase
{
public ICommand SecondPageCommand { get; set; }
public NavigationRootViewModel()
{
SecondPageCommand = DelegateCommand.FromAsyncHandler(ExecuteMethod);
}
private Task ExecuteMethod()
{
return Task.FromResult(0);
}
}
我希望在构造函数中注入 INavigationService,但它不是 Prism.Core dll 的一部分。
那么正确的做法是什么?甚至可以使用 Prism 在 PCL 中导航吗?在 MvvmCross 中是...
【问题讨论】:
标签: c# navigation uwp prism printer-control-language