码迷,mamicode.com
首页 > 其他好文 > 详细

[XAF]如何在非按钮事件中打开视图

时间:2015-05-16 21:46:54      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

 1  private static void OpenDetailView(XafApplication app) {
 2             IObjectSpace os = app.CreateObjectSpace();
 3             //Find an existing object.
 4             //Contact obj = os.FindObject<Contact>(CriteriaOperator.Parse("FirstName=?", "My Contact"));
 5             //Or create a new object.
 6             Contact obj = os.CreateObject<Contact>();
 7             obj.FirstName = "My Contact";
 8             //Save the changes if necessary.
 9             //os.CommitChanges();
10             //Configure how our View will be displayed (all parameters except for the CreatedView are optional).
11             ShowViewParameters svp = new ShowViewParameters();
12             svp.CreatedView = app.CreateDetailView(os, obj);
13             //svp.TargetWindow = TargetWindow.NewModalWindow;
14             //svp.Context = TemplateContext.PopupWindow;
15             //svp.CreateAllControllers = true;
16             //You can pass custom Controllers for intercommunication or to provide a standard functionality (e.g., functionality of a dialog window).
17             //DialogController dc = Application.CreateController<DialogController>();
18             //svp.Controllers.Add(dc);
19             // Show our View once the ShowViewParameters object is initialized.
20             app.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
21         }

另外一种方法,

1 ShowViewParameters svp = new ShowViewParameters();
2 ViewShortcut shortcut = new ViewShortcut(Application.FindDetailViewId(typeof(Contact)), obj.Oid);
3 svp.CreatedView = Application.ProcessShortcut(shortcut);

 

[XAF]如何在非按钮事件中打开视图

标签:

原文地址:http://www.cnblogs.com/lsr-flying/p/4508708.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!