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);
时间: 2024-09-30 10:46:44