zoukankan      html  css  js  c++  java
  • ModernUI + MVVM 导航

    在主窗体中注册消息

    1. Messenger.Default.Register<string>(this, pageuri =>  
    2.     {  
    3.         var frame = GetDescendantFromName(this, "ContentFrame") as ModernFrame;  
    4.             
    5.         // Set the frame source, which initiates navigation  
    6.         if (frame != null)  
    7.         {  
    8.             frame.Source = new Uri(p.Page, UriKind.Relative);  
    9.         }  
    10.     });

    主窗体中获取FRAME的方法

    1. private   static FrameworkElement GetDescendantFromName(DependencyObject parent,  string name)  
    2.     {  
    3.         var count = VisualTreeHelper.GetChildrenCount(parent);  
    4.    
    5.          if  (count < 1)  
    6.         {  
    7.              return   null ;  
    8.         }  
    9.    
    10.          for  (var i = 0; i < count; i++)  
    11.         {  
    12.             var frameworkElement = VisualTreeHelper.GetChild(parent, i)  as FrameworkElement;  
    13.              if  (frameworkElement !=  null )  
    14.             {  
    15.                  if  (frameworkElement.Name == name)  
    16.                 {  
    17.                      return  frameworkElement;  
    18.                 }  
    19.    
    20.                 frameworkElement = GetDescendantFromName(frameworkElement, name);  
    21.                  if  (frameworkElement !=  null )  
    22.                 {  
    23.                      return  frameworkElement;  
    24.                 }  
    25.             }  
    26.         }  
    27.    
    28.          return   null ;  
    29.     }  
    30. }  

    在页面中的导航请求

    Messenger.Default.Send(pageuri);

    ----------------------------------------------------------------------------------------------------------

    按钮导航

  • 相关阅读:
    java 21
    maven POM.xml 标签详解
    shell sed 替代1
    lua的table库中的常用函数总结
    Lua字符串及模式匹配
    lua文件读写
    qt添加lua支持
    关于c调用lua 对‘luaL_newstate()’未定义的引用的问题解决办法
    Lua开发环境
    linux安装lua相关编译报错
  • 原文地址:https://www.cnblogs.com/zhangxiaoshuai/p/5582800.html
Copyright © 2011-2022 走看看