@@ -34,7 +34,16 @@ public void HandleApplicationEvents(Application application, bool bind = true)
3434 {
3535 if ( bind )
3636 {
37- // Attach element events to all descendents as they are added to the application.
37+ // Attach element events to all existing descendants.
38+ foreach ( var descendant in application . GetVisualTreeDescendants ( ) . Skip ( 1 ) )
39+ {
40+ if ( descendant is VisualElement element )
41+ {
42+ OnApplicationOnDescendantAdded ( application , new ElementEventArgs ( element ) ) ;
43+ }
44+ }
45+
46+ // Attach element events to all descendants as they are added to the application.
3847 application . DescendantAdded += OnApplicationOnDescendantAdded ;
3948 application . DescendantRemoved += OnApplicationOnDescendantRemoved ;
4049
@@ -45,8 +54,6 @@ public void HandleApplicationEvents(Application application, bool bind = true)
4554 }
4655
4756 // Navigation events
48- application . PageAppearing += OnApplicationOnPageAppearing ;
49- application . PageDisappearing += OnApplicationOnPageDisappearing ;
5057 application . ModalPushed += OnApplicationOnModalPushed ;
5158 application . ModalPopped += OnApplicationOnModalPopped ;
5259
@@ -62,8 +69,6 @@ public void HandleApplicationEvents(Application application, bool bind = true)
6269 HandleElementEvents ( application , bind : false ) ;
6370
6471 // Navigation events
65- application . PageAppearing -= OnApplicationOnPageAppearing ;
66- application . PageDisappearing -= OnApplicationOnPageDisappearing ;
6772 application . ModalPushed -= OnApplicationOnModalPushed ;
6873 application . ModalPopped -= OnApplicationOnModalPopped ;
6974
0 commit comments