MVVM Cross ShowViewModel在自定义的UWP上不起作用

NPadrutt

我从这个StackOverflow问题中引用了有关MVVM Light的信息:

我正在尝试使用汉堡包菜单样式导航(请参阅此示例)。Microsoft提供的有关如何执行此操作的示例)来实现以下目的:

1-拥有在我所有页面上共享的便捷解决方案。上面提到的示例使用AppShell页面作为应用程序的根目录而不是框架,该框架封装了导航菜单和后退按钮的某些行为。那将是理想的。

2-使用MVVM-Light导航服务可以方便地处理我的视图模型中的所有导航。

这是App.xml.Cs在launched上初始化外壳页面的方式:

 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中进行构建。

谢谢NPadrutt

NPadrutt

奥奇这很尴尬。问题是无法解析ViewModel的View。这样做的原因是我没有替换从页面到视图的继承:MvxWindowsPage。这样,所有内容都可以与默认页面演示者一起使用。

编辑:为了与应用程序外壳中的导航一起使用,这些页面需要为Pages。因此,您可能不得不重写Appshell中的导航,或者可能没有将所有页面调整为MvxPage。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章