zoukankan      html  css  js  c++  java
  • Devexpress xaf用代码打开菜单(Navigation Item)

    第一种:ViewController继承WindowController

     public abstract class MyWindowController : WindowController
     {
            public MyWindowController()
            {
          InitializeComponent();
            }
            protected override void OnActivated()
            {
                base.OnActivated();
                DevExpress.ExpressApp.SystemModule.ShowNavigationItemController svc =
                 Frame.GetController<DevExpress.ExpressApp.SystemModule.ShowNavigationItemController>();
                SingleChoiceAction action = svc.ShowNavigationItemAction;
                ChoiceActionItem toSelect = action.FindItemByIdPath("菜单路径");
                if (toSelect == null)
                {
                    XtraMessageBox.Show("未找到XX的菜单", GlobalConst.SystemTitle);
                }
                else
                {
                    action.DoExecute(toSelect);
                }
            }
    }
    

    第二种方式:ViewController不继承WindowController

     public partial class MyViewController: ViewController
     {
            public MyViewController()
            {
          InitializeComponent();
            }
            protected override void OnActivated()
            {
                base.OnActivated();
                DevExpress.ExpressApp.SystemModule.ShowNavigationItemController svc =
                 Application.MainWindow.GetController<DevExpress.ExpressApp.SystemModule.ShowNavigationItemController>();
                SingleChoiceAction action = svc.ShowNavigationItemAction;
                ChoiceActionItem toSelect = action.FindItemByIdPath("菜单路径");
                if (toSelect == null)
                {
                    XtraMessageBox.Show("未找到XX的菜单", GlobalConst.SystemTitle);
                }
                else
                {
                    action.DoExecute(toSelect);
                }
            }
    }
    

    两者的区别就是一个通过Frame获取ShowNavigationItemController对象,另一个通过Application.MainWindow获取ShowNavigationItemController对象。

  • 相关阅读:
    观察者模式
    hdu 4712 Hamming Distance bfs
    leetcode Sum Root to Leaf Numbers(所有路径之和)
    Oracle实用-01:绑定变量
    jQuery实现AJAX定时刷新局部页面实例
    给Ajax一个漂亮的嫁衣——Ajax系列之五(下)之序列化和反序列化
    jquery的ajax同步和异步
    报表技术
    告别.NET生成报表统计图的烦恼
    浅谈ASP.NET报表控件
  • 原文地址:https://www.cnblogs.com/xiaomianyang/p/11899303.html
Copyright © 2011-2022 走看看