@@ -52,6 +52,85 @@ public ComponentAsDialogOptions(Type componentType)
5252 /// Allows you to set the dialog size. Ignored when the dialog is <see cref="Dialog.IsCustom" />.
5353 /// </summary>
5454 public DialogSize Size { get ; set ; } = DialogSize . Normal ;
55+
56+ /// <summary>
57+ /// An event that is triggered before the dialog appears.
58+ /// </summary>
59+ public Func < DialogBeforeShowEventArgs , Task > ? OnBeforeShow { get ; set ; }
60+
61+ /// <summary>
62+ /// An event that is triggered after the dialog appears.
63+ /// </summary>
64+ public Func < DialogAfterShowEventArgs , Task > ? OnAfterShow { get ; set ; }
65+
66+ /// <summary>
67+ /// An event that is triggered before the dialog hides.
68+ /// </summary>
69+ public Func < DialogBeforeHideEventArgs , Task > ? OnBeforeHide { get ; protected set ; }
70+
71+ /// <summary>
72+ /// An event that is triggered after the dialog hides.
73+ /// </summary>
74+ public Func < DialogAfterHideEventArgs , Task > ? OnAfterHide { get ; protected set ; }
75+
76+ public Func < bool , Task > ? OnAfterRender { get ; protected set ; }
77+
78+ internal event Func < Task > OnOptionsChanged ;
79+
80+ ///// <summary>
81+ ///// An event that is triggered before the dialog appears.
82+ ///// </summary>
83+ //public async Task SetOnBeforeShow(Func<DialogBeforeShowEventArgs, Task> func)
84+ //{
85+ // OnBeforeShow = func;
86+ // await RefreshDialog();
87+ //}
88+
89+ ///// <summary>
90+ ///// An event that is triggered after the dialog appears.
91+ ///// </summary>
92+ //public async Task SetOnAfterShow(Func<DialogAfterShowEventArgs, Task> func)
93+ //{
94+ // OnAfterShow = func;
95+ // await RefreshDialog();
96+ //}
97+
98+ /// <summary>
99+ /// An event that is triggered before the dialog hides.
100+ /// </summary>
101+ public async Task SetOnBeforeHide ( Func < DialogBeforeHideEventArgs , Task > func )
102+ {
103+ OnBeforeHide = func ;
104+ await RefreshDialog ( ) ;
105+ }
106+
107+ /// <summary>
108+ /// An event that is triggered after the dialog hides.
109+ /// </summary>
110+ public async Task SetOnAfterHide ( Func < DialogAfterHideEventArgs , Task > func )
111+ {
112+ OnAfterHide = func ;
113+ await RefreshDialog ( ) ;
114+ }
115+
116+ /// <summary>
117+ /// An event that is triggered after the dialog hides.
118+ /// </summary>
119+ public async Task SetOnAfterRender ( Func < bool , Task > func )
120+ {
121+ OnAfterRender = func ;
122+ await RefreshDialog ( ) ;
123+ }
124+
125+ /// <summary>
126+ /// Use to redraw the dialog if any options are changed.
127+ /// </summary>
128+ /// <returns></returns>
129+ public async Task RefreshDialog ( )
130+ {
131+ var result = OnOptionsChanged ? . Invoke ( ) ;
132+ if ( result != null ) await result ;
133+ }
55134 }
56135
57136 public class ComponentDialog
0 commit comments