Specify Action Settings 指定按钮设置

In this lesson, you will learn how to modify Action properties. The ClearTasks Action will be used. To see how the Action was implemented, refer to the Add a Simple Action lesson. In this lesson, you will add a tooltip, confirmation message and shortcut to it.

在本课中,您将学习如何修改 Action 属性。将使用清除任务操作。要查看操作是如何实现的,请参阅添加简单按钮课程。在本课中,您将向其添加工具提示、确认消息和快捷方式。

Note 注意

Before proceeding, take a moment to review the following lessons.

在继续之前,请花点时间复习以下课程。

  • Add a Simple Action
  • Place an Action in a Different Location
  • Since the ClearTasksAction is implemented in the common application module, you can specify its properties directly in this module. To do this, invoke the Model Editor by double-clicking the Model.DesignedDiffs.xafml file in the MySolution.Module project:
  • In the Model Editor, navigate to the ActionDesign | Actions node. Locate the ClearTasksAction node. To the right, the Action's settings are represented by properties. These properties are separated into collapsible categories.
  • Navigate to the Misc category. By default, the Tooltip property is set to Caption. Set it to "Clear the current Contact's tasks" instead. Set the Shortcut property to "Control+Shift+C", to specify a shortcut for the Action. Note that the specified shortcut will be displayed along with the Tooltip property value in the Action's tooltip. By default, the ConfirmationMessage property is set to the Action's ActionBase.ConfirmationMessage property value, which is specified in code. Replace this value with "Are you sure you want to clear the {0}'s Tasks list?". The "{0}" format item will be substituted with the object's default property value. A property can be specified as default via the DefaultProperty property of the BOModel | <Class> node in the Model Editor. Alternatively, the DefaultProperty attribute can be applied to the property's business class declaration.

  • 添加简单操作
  • 将操作放置在其他位置
  • 由于 ClearTasksAction 是在通用应用程序模块中实现的,因此可以直接在此模块中指定其属性。为此,请通过双击"模型.设计Diffs.xafml"项目中的"模型编辑器"来调用模型编辑器:
  • 在模型编辑器中,导航到操作设计 |操作节点。找到"清除任务操作"节点。在右侧,操作的设置由属性表示。这些属性被分隔成可折叠的类别。
  • 导航到杂项类别。默认情况下,"工具提示"属性设置为"标题"。请改为将其设置为"清除当前联系人的任务"。将快捷方式属性设置为"控制_Shift_C",以指定操作的快捷方式。请注意,指定的快捷方式将与"工具提示"工具提示中的"工具提示"属性值一起显示。默认情况下,"确认消息"属性设置为操作的操作Base.确认消息属性值,该属性值在代码中指定。将此值替换为"是否确实要清除{0}的任务列表?""{0}"格式项将替换为对象的默认属性值。可以通过 BOModel 的"默认属性"属性将属性指定为默认值 |模型编辑器中的<Class>节点。或者,DefaultProperty 属性可以应用于属性的业务部门级声明。
Note 注意
Shortcuts are defined by simple strings that you need to type manually. The IModelAction.Shortcut property is used to parse the strings. Note that shortcuts will only work in a WinForms application.

快捷方式由需要手动键入的简单字符串定义。IModelAction.快捷方式属性用于分析字符串。请注意,快捷方式仅在 WinForms 应用程序中工作。

The current object identifier will be inserted into the confirmation message if the Action's SelectionDependencyType property is not set to "Independent". So, assign the "RequireSingleObject" value to the SelectionDependencyType property. This property belongs to the Behavior category. You can also set this property to "RequireMultipleObjects". In this case, the count of selected objects will be substituted to the confirmation message.
如果操作的"选择依赖类型"属性未设置为"独立",则当前对象标识符将插入到确认消息中。因此,将"需要单一对象"值分配给选择依赖类型属性。此属性属于行为类别。您还可以将此属性设置为"需要多个对象"。在这种情况下,所选对象的计数将替换为确认消息。

Tutorial_UIC_Lesson2_1

  • Run the WinForms or ASP.NET application and invoke the Detail View of any object, by double-clicking an existing one or creating a new one. Check to see if the Clear Tasks button has the required tooltip, can be executed via the specified shortcut, and a confirmation message with the specified text is invoked.
  • 通过双击现有对象或创建新对象,运行 WinForms 或ASP.NET应用程序并调用任何对象的详细信息视图。检查"清除任务"按钮是否具有所需的工具提示,是否可以通过指定的快捷方式执行,并调用包含指定文本的确认消息。

WinForms Application

WinForms 应用程序

Tutorial_UIC_Lesson2_3

ASP.NET Application

ASP.NET应用程序

Tutorial_UIC_Lesson2_4

Note 注意

You can also set an image for an Action. For details, refer to the Assign a Custom Image topic.

您还可以为操作设置图像。有关详细信息,请参阅分配自定义图像主题。

You can see the changes made in this lesson in the Model Editor invoked for the Model.DesignedDiffs.xafml file, located in the Main Demo | MainDemo.Module project. The MainDemo application is installed in %PUBLIC%DocumentsDevExpress Demos 19.2ComponentseXpressApp FrameworkMainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/

您可以在本课中为模型调用的模型编辑器中所做的更改。主演示模块项目。主演示应用程序安装在%PUBLIC%DocumentsDevExpress Demos 19.2ComponentseXpressApp FrameworkMainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/

.

原文地址:https://www.cnblogs.com/foreachlife/p/Specify-Action-Settings.html