2015-08-27 30 views
3

我从this StackOverflow的问题是指正常工作,就到MVVM光:MVVM跨ShowViewModel不会对UWP定制

我想有一个汉堡包菜单式的导航(见本 样品)。应用程序由微软如何做到这一点的例子):

1-有一个方便的解决方案共享我的所有网页。上面提到的示例 使用AppShell Page作为应用程序的根,而不是一个Frame的 ,它封装了导航菜单以及后退按钮的一些行为。这将是理想的。

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

这里是App.xml.Cs如何初始化onLaunched外壳页:

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一切正常proviced菜单。但MVVM Cross的ShowViewModel没有任何效果。 我认为如果将外壳作为框架或框架设置在AppShell上,应该没有任何区别。 有没有人有一个想法,我可以做些什么呢,或者如果有MVVM跨工作汉堡菜单的例子?

如果您需要更好的概述,存储库是GitHub上的开源代码。

https://github.com/Apply-Solutions/MoneyManager

我用MVVM跨V4.0.0.0-β1。 Beta2目前还有一个问题是阻止在UWP中建设。

感谢 NPadrutt

回答

0

Okey这个尴尬。问题是ViewModel的View无法解析。原因是我没有替换页面间的继承:MvxWindowsPage。 有了这个,所有东西都可以与默认页面展示器一起使用。

编辑:为了在应用程序外壳中的导航工作,这些网页需要页面。因此,您可能必须重写Appshell中的导航,或者可能不会将所有页面调整为MvxPage。

0

不完全知道你正在尝试做的,但你可能会需要使用MvvmCross作为一个框架UWP应用汉堡包菜单导航页面是什么,是一个自定义的主持人,这处理ShowViewModel方法,并在汉堡容器视图中显示请求的ViewModel的相关视图。