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