【发布时间】:2015-08-30 21:38:06
【问题描述】:
我参考this StackOverflow 问题,关于 MVVM Light:
我正在尝试使用汉堡菜单样式导航(请参阅此 样本)。由 Microsoft 提供的有关如何执行此操作的示例)到:
1- 在我的所有页面上共享一个方便的解决方案。样本 上面提到的使用 AppShell Page 作为应用程序的根目录 一个框架,它封装了导航菜单和一些行为 后退按钮。那将是理想的。
2- 使用 MVVM-Light 导航服务来处理所有导航 方便地从我的视图模型中。
下面是 App.xml.Cs 如何在启动时初始化 shell 页面:
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
var shell = Window.Current.Content as AppShell;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (shell == null)
{
// Create a AppShell to act as the navigation context and navigate to the first page
shell = new AppShell();
// Set the default language
shell.Language = ApplicationLanguages.Languages[0];
shell.AppFrame.NavigationFailed += OnNavigationFailed;
}
// Place our app shell in the current Window
Window.Current.Content = shell;
if (shell.AppFrame.Content == null)
{
// When the navigation stack isn't restored, navigate to the first page
// suppressing the initial entrance animation.
var setup = new Setup(shell.AppFrame);
setup.Initialize();
var start = Mvx.Resolve<IMvxAppStart>();
start.Start();
}
// Ensure the current window is active
Window.Current.Activate();
}
问题是,只要我浏览 AppShell 提供的菜单,一切正常。但是 MVVM Cross 的 ShowViewModel 没有任何效果。 我认为如果将 shell 作为 Frame 或在 AppShell 上设置的框架传递,应该没有任何区别。 有谁知道我能做些什么,或者是否有一个带有 MVVM cross 的汉堡菜单示例?
如果您需要更好的概览,该存储库在 GitHub 上是开源的。
https://github.com/Apply-Solutions/MoneyManager
我使用 MVVM Cross v4.0.0.0-beta1。 Beta2 目前还有一个问题会阻止在 UWP 中构建。
谢谢 帕德鲁特
【问题讨论】: