@@ -242,7 +242,24 @@ private static void IsPopupOpenPropertyChangedCallback(DependencyObject dependen
242
242
else
243
243
Mouse . Capture ( null ) ;
244
244
}
245
-
245
+ if ( newValue )
246
+ {
247
+ var popupOpenedEventArgs = new RoutedEventArgs ( )
248
+ {
249
+ RoutedEvent = PopupOpenedEvent ,
250
+ Source = popupBox
251
+ } ;
252
+ popupBox . RaiseEvent ( popupOpenedEventArgs ) ;
253
+ }
254
+ else
255
+ {
256
+ var popupClosedEventArgs = new RoutedEventArgs ( )
257
+ {
258
+ RoutedEvent = PopupClosedEvent ,
259
+ Source = popupBox
260
+ } ;
261
+ popupBox . RaiseEvent ( popupClosedEventArgs ) ;
262
+ }
246
263
247
264
popupBox . AnimateChildrenIn ( ! newValue ) ;
248
265
popupBox . _popup ? . RefreshPosition ( ) ;
@@ -259,6 +276,45 @@ public bool IsPopupOpen
259
276
set { SetValue ( IsPopupOpenProperty , value ) ; }
260
277
}
261
278
279
+ /// <summary>
280
+ /// Event corresponds to the popup opening
281
+ /// </summary>
282
+ public static readonly RoutedEvent PopupOpenedEvent =
283
+ EventManager . RegisterRoutedEvent (
284
+ "PopupOpened" ,
285
+ RoutingStrategy . Bubble ,
286
+ typeof ( RoutedEventHandler ) ,
287
+ typeof ( PopupBox ) ) ;
288
+
289
+ /// <summary>
290
+ /// Event corresponds to the popup closing
291
+ /// </summary>
292
+ public static readonly RoutedEvent PopupClosedEvent =
293
+ EventManager . RegisterRoutedEvent (
294
+ "PopupClosed" ,
295
+ RoutingStrategy . Bubble ,
296
+ typeof ( RoutedEventHandler ) ,
297
+ typeof ( PopupBox ) ) ;
298
+
299
+ /// <summary>
300
+ /// Add / Remove PopupOpenedEvent handler
301
+ /// </summary>
302
+ public event RoutedEventHandler PopupOpened
303
+ {
304
+ add { AddHandler ( PopupOpenedEvent , value ) ; }
305
+ remove { RemoveHandler ( PopupOpenedEvent , value ) ; }
306
+ }
307
+
308
+ /// <summary>
309
+ /// Add / Remove PopupClosedEvent handler
310
+ /// </summary>
311
+ public event RoutedEventHandler PopupClosed
312
+ {
313
+ add { AddHandler ( PopupClosedEvent , value ) ; }
314
+ remove { RemoveHandler ( PopupClosedEvent , value ) ; }
315
+ }
316
+
317
+
262
318
public static readonly DependencyProperty StaysOpenProperty = DependencyProperty . Register (
263
319
nameof ( StaysOpen ) , typeof ( bool ) , typeof ( PopupBox ) , new PropertyMetadata ( default ( bool ) ) ) ;
264
320
0 commit comments