幽梦紫曦

XAF弹窗按钮弹出自定义窗体

电脑版发表于:2020/11/12 16:15
  1. 加载CustomizePopupWindowParams事件并创建窗体弹出

  2. private void popupWindowShowAction1_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)

  3. {

  4.       //创建IObjectSpace对象

  5.       IObjectSpace space = Application.CreateObjectSpace();

  6.      //创建SelectCondition对象

  7.      SelectCondition condition = space.CreateObject<SelectCondition>();

  8.      //创建DetailView对象

  9.      DetailView view = Application.CreateDetailView(space, condition, true);

  10.      //设置编辑模式为可编辑

  11.      view.ViewEditMode = ViewEditMode.Edit;

  12.      //将DetailView添加到视图

  13.      e.View = view;

  14. }


  15. 在模型编辑器里找到bo复制一个ListView


  16. 加载Execute点击事件并创建新的窗体以及按钮

  17. private void popupWindowShowAction1_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)

  18. {

  19.       //获取视图窗体对象

  20.       DetailView view = e.PopupWindowView as DetailView;

  21.      //将其转换为实体对象

  22.      SelectCondition condition = view.CurrentObject as SelectCondition;

  23.      //创建IObjectSpace对象

  24.      IObjectSpace space = Application.CreateObjectSpace();

  25.      //创建ListView对象

  26.      ListView listView = Application.CreateListView("Factoryinfo_Custom_ListView", new CollectionSource(space, typeof(Factoryinfo)), false);

  27.      //创建窗体视图

  28.      e.ShowViewParameters.CreatedView = listView;

  29.      //设置窗体上下文

  30.      e.ShowViewParameters.Context = TemplateContext.PopupWindow;

  31.      //新建一个窗体

  32.      e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;

  33.      DialogController controller = new DialogController();

  34.      controller.AcceptAction.Caption = "确定";

  35.      controller.CancelAction.Caption = "取消";

  36.      e.ShowViewParameters.Controllers.Add(controller);

  37. }

  38. 注:Factoryinfo_Custom_ListView是ListView ID


  39. 效果:


关于TNBLOG
TNBLOG,技术分享
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢