@@ -209,22 +209,22 @@ public event DialogClosingEventHandler DialogClosing
209
209
add { AddHandler ( DialogClosingEvent , value ) ; }
210
210
remove { RemoveHandler ( DialogClosingEvent , value ) ; }
211
211
}
212
-
212
+
213
213
/// <summary>
214
214
/// Attached property which can be used on the <see cref="Button"/> which instigated the <see cref="OpenDialogCommand"/> to process the closing event.
215
215
/// </summary>
216
- public static readonly DependencyProperty DialogClosingProperty = DependencyProperty . RegisterAttached (
217
- "DialogClosing " , typeof ( DialogClosingEventHandler ) , typeof ( DialogHost ) , new PropertyMetadata ( default ( DialogClosingEventHandler ) ) ) ;
216
+ public static readonly DependencyProperty DialogClosingAttachedProperty = DependencyProperty . RegisterAttached (
217
+ "DialogClosingAttached " , typeof ( DialogClosingEventHandler ) , typeof ( DialogHost ) , new PropertyMetadata ( default ( DialogClosingEventHandler ) ) ) ;
218
218
219
- public static void SetDialogClosing ( DependencyObject element , DialogClosingEventHandler value )
219
+ public static void SetDialogClosingAttached ( DependencyObject element , DialogClosingEventHandler value )
220
220
{
221
- element . SetValue ( DialogClosingProperty , value ) ;
221
+ element . SetValue ( DialogClosingAttachedProperty , value ) ;
222
222
}
223
223
224
- public static DialogClosingEventHandler GetDialogClosing ( DependencyObject element )
224
+ public static DialogClosingEventHandler GetDialogClosingAttached ( DependencyObject element )
225
225
{
226
- return ( DialogClosingEventHandler ) element . GetValue ( DialogClosingProperty ) ;
227
- }
226
+ return ( DialogClosingEventHandler ) element . GetValue ( DialogClosingAttachedProperty ) ;
227
+ }
228
228
229
229
public static readonly DependencyProperty DialogClosingCallbackProperty = DependencyProperty . Register (
230
230
"DialogClosingCallback" , typeof ( DialogClosingEventHandler ) , typeof ( DialogHost ) , new PropertyMetadata ( default ( DialogClosingEventHandler ) ) ) ;
@@ -239,9 +239,7 @@ public DialogClosingEventHandler DialogClosingCallback
239
239
}
240
240
241
241
protected void OnDialogClosing ( DialogClosingEventArgs eventArgs )
242
- {
243
- eventArgs . RoutedEvent = DialogClosingEvent ;
244
- eventArgs . Source = eventArgs . Source ?? this ;
242
+ {
245
243
RaiseEvent ( eventArgs ) ;
246
244
}
247
245
@@ -252,7 +250,7 @@ private void OpenDialogHandler(object sender, ExecutedRoutedEventArgs executedRo
252
250
var dependencyObject = executedRoutedEventArgs . OriginalSource as DependencyObject ;
253
251
if ( dependencyObject != null )
254
252
{
255
- _attachedDialogClosingEventHandler = GetDialogClosing ( dependencyObject ) ;
253
+ _attachedDialogClosingEventHandler = GetDialogClosingAttached ( dependencyObject ) ;
256
254
}
257
255
258
256
if ( executedRoutedEventArgs . Parameter != null )
@@ -279,17 +277,17 @@ private void CloseDialogHandler(object sender, ExecutedRoutedEventArgs executedR
279
277
{
280
278
if ( executedRoutedEventArgs . Handled ) return ;
281
279
282
- var dialogClosingEventArgs = new DialogClosingEventArgs ( executedRoutedEventArgs . Parameter , DialogContent ) ;
280
+ var dialogClosingEventArgs = new DialogClosingEventArgs ( executedRoutedEventArgs . Parameter , DialogContent , DialogClosingEvent ) ;
283
281
284
282
//multiple ways of calling back that the dialog is closing:
283
+ // * routed event
285
284
// * the attached property (which should be applied to the button which opened the dialog
286
285
// * straight forward dependency property
287
286
// * handler provided to the async show method
288
- // * routed event
287
+ OnDialogClosing ( dialogClosingEventArgs ) ;
289
288
_attachedDialogClosingEventHandler ? . Invoke ( this , dialogClosingEventArgs ) ;
290
289
DialogClosingCallback ? . Invoke ( this , dialogClosingEventArgs ) ;
291
290
_asyncShowClosingEventHandler ? . Invoke ( this , dialogClosingEventArgs ) ;
292
- OnDialogClosing ( dialogClosingEventArgs ) ;
293
291
294
292
if ( ! dialogClosingEventArgs . IsCancelled )
295
293
SetCurrentValue ( IsOpenProperty , false ) ;
0 commit comments