Dialog Controller(对话框控制器)
The XAF has several Controllers that are automatically added to each Frame and provide basic functionality in applications (NewObjectViewController, ShowNavigationItemController, etc.). However, this does not include the DialogController- you need to add it manually if it is required. It is used to add the Accept and Cancel buttons in pop-up Windows. For instance, the Dialog Controller is contained in the pop-up Window that is invoked by a PopupWindowShowAction. This Controller provides the OK and Cancel buttons. This topic describes the Dialog Controller’s behavior and how to use it in a pop-up Window.
XAF有几个控制器,它们会自动添加到每个框架中,并在应用程序(NewObjectViewController、ShowNavigationItemController等)中提供基本功能。但是,这不包括对话框控制器——如果需要,您需要手动添加它。它用于在弹出窗口中添加接受和取消按钮。例如,对话框控制器包含在由PopupWindowShowAction调用的弹出窗口中。此控制器提供确定和取消按钮。本主题描述对话框控制器的行为以及如何在弹出窗口中使用它。
Dialog Controller Overview(对话框控制器概述)
The DialogController is inherited from the WindowController class. It contains the following Actions:
DialogController继承自WindowController类。它包含以下操作:
The Dialog Controller has the following specificities:
对话控制器具有以下特性:
- If a pop-up Window with the Dialog Controller displays a List View, the ListViewProcessCurrentObjectController.ProcessCurrentObjectAction (executed when you click or double-click a row) closes the pop-up window and accepts the dialog. This behavior is designed for Lookup List Views. To cancel closing the pop-up Window and process the ProcessCurrentObjectAction as in regular windows, set the DialogController.CloseOnCurrentObjectProcessing property to false.
如果带有对话框控制器的弹出窗口显示列表视图,ListViewProcessCurrentObjectController。ProcessCurrentObjectAction(单击或双击一行时执行)关闭弹出窗口并接受对话框。此行为是为查找列表视图设计的。要取消关闭弹出窗口并像在常规窗口中一样处理ProcessCurrentObjectAction,请将对话框控制器。CloseOnCurrentObjectProcessing属性设置为false。 - In addition to Dialog Controller members related to Actions, there is a DialogController.WindowTemplateChanged event. Handle it if you need to customize the Template assigned to a pop-up Window.
除了与Actions相关的Dialog Controller成员之外,还有一个DialogController.WindowTemplateChanged事件。如果您需要自定义分配给弹出窗口的模板,请处理它。 - You can customize the DialogController class by inheriting from it.
您可以通过继承来自定义DialogController类。 - Dialog Controllers are not added to a Frame’s Frame.Controllers collection automatically. You need to add them manually when required.
对话框控制器不会自动添加到框架的框架.控制器集合中。您需要在需要时手动添加它们。
Dialog Controllers in Pop-up Windows Invoked via ShowViewParameters Objects(通过ShowViewParameter对象调用弹出窗口中的对话控制器)
To invoke a Window after an Action is executed, specify an ActionBaseEventArgs.ShowViewParameters parameter of the Action’s Execute event handler. The following conditions should be satisfied to create the invoked Window pop-up application:
要在Action执行后调用Window,请指定Action的Execute事件处理程序的ActionBaseEventArgs. ShowViewParameter参数。创建调用的Window弹出应用程序应满足以下条件:
- The ShowViewParameters.TargetWindow property is set to TargetWindow.NewModalWindow, and the ShowViewParameters.Context property is set to TemplateContext.PopupWindow.
ShowViewParameters. TargetWindow属性设置为TargetWindow.NewModalWindow,ShowViewParameters.Context属性设置为TemplateContext.PopupWindow。 - The TargetWindow property is set to TargetWindow.NewModalWindow, the Context property is set to TemplateContext.Undefined (default value), and the ShowViewParameters.Controllers collection is not empty.
TargetWindow属性设置为TargetWindow. NewModalWindow,Context属性设置为TemplateContext.Undefined(默认值),并且ShowViewParameter.Controller集合不为空。 - The TargetWindow property is set to TargetWindow.NewWindow, and the Context property is set to PopupWindow.
TargetWindow属性设置为TargetWindow. NewWindow,Context属性设置为PopupWindow。 - In SDI mode, the TargetWindow property is set to TargetWindow.NewWindow, the Context property is set to TemplateContext.Undefined (default value), and the ShowViewParameters.Controllers collection is not empty.
在SDI模式下,TargetWindow属性设置为TargetWindow. NewWindow,Context属性设置为TemplateContext.Undefined(默认值),并且ShowViewParameter.Controller集合不为空。
To add a Dialog Controller to the pop-up window, use the ShowViewParameters.Controllers parameter of the Action’s Execute event handler. The following code demonstrates how to create a List View in a pop-up window and add a Dialog Controller:
要将Dialog Controller添加到弹出窗口,请使用Action的Execute事件处理程序的ShowViewParameter. Controller参数。以下代码演示了如何在弹出窗口中创建列表视图并添加Dialog Controller:
C#
using DevExpress.ExpressApp.SystemModule;
// ...
void myAction_Execute(Object sender, SimpleActionExecuteEventArgs e) {
IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(MyBusinessClass));
string listViewId = Application.FindListViewId(typeof(MyBusinessClass));
e.ShowViewParameters.CreatedView = Application.CreateListView(
listViewId,
Application.CreateCollectionSource(objectSpace, typeof(MyBusinessClass), listViewId),
true);
e.ShowViewParameters.TargetWindow = TargetWindow.NewWindow;
e.ShowViewParameters.Context = TemplateContext.PopupWindow;
e.ShowViewParameters.Controllers.Add(Application.CreateController<DialogController>());
}
Note
- You can add the built-in DialogController or a custom one that is inherited from it.
您可以添加内置的DialogController或从它继承的自定义DialogController。- If the ShowViewParameters.CreateAllControllers property is set to false and you want the Actions’ buttons in a Template, add the FillActionContainersController to the Controllers collection.
如果ShowViewParameter.CreateAllControllers属性设置为false,并且您希望模板中的Actions按钮,请将FillActionContainersController添加到Controller集合中。
Dialog Controllers in Pop-up Windows Invoked via PopupWindowShowAction Type Actions(通过PopupWindowShowAction类型操作调用弹出窗口中的对话框控制器)
The pop-up Windows which are invoked when pressing a Pop-up Window Show Action contain a DialogController type Dialog Controller. You can change the behavior of the Dialog Controller’s Actions as follows:
按下弹出窗口显示操作时调用的弹出窗口包含DialogController类型的Dialog Controller。您可以更改Dialog Controller的操作的行为,如下所示:
You can use the PopupWindowShowAction.CustomizePopupWindowParams event handler’s CustomizePopupWindowParamsEventArgs.DialogController parameter to customize the default Dialog Controller the pop-up Window uses. You can also replace this Dialog Controller with a custom one. The code below demonstrates creating a List View in a Pop-up Window and adding a custom Dialog Controller.
您可以使用PopupWindowShowAction.CustomizePopupWindowParams事件处理程序的CustomizePopupWindowParamsEventArgs. DialogController参数来自定义弹出窗口使用的默认对话框控制器。您也可以将此对话框控制器替换为自定义控制器。下面的代码演示了在弹出窗口中创建列表视图和添加自定义对话框控制器。
C#
private void MyPopupWindowShowAction_CustomizePopupWindowParams(object sender,
CustomizePopupWindowParamsEventArgs e) {
IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(MyBusinessClass));
string listViewId = Application.FindListViewId(typeof(MyBusinessClass));
e.View = Application.CreateListView(
listViewId,
Application.CreateCollectionSource(objectSpace, typeof(MyBusinessClass), listViewId),
true);
e.DialogController = Application.CreateController<MyDialogController>();
}
标签:02,控制器,05,对话框,up,Controller,Dialog,DialogController,TargetWindow
From: https://blog.csdn.net/thomastang200912_126/article/details/144803750