@@ -34,7 +34,16 @@ public void HandleApplicationEvents(Application application, bool bind = true)
34
34
{
35
35
if ( bind )
36
36
{
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.
38
47
application . DescendantAdded += OnApplicationOnDescendantAdded ;
39
48
application . DescendantRemoved += OnApplicationOnDescendantRemoved ;
40
49
@@ -45,8 +54,6 @@ public void HandleApplicationEvents(Application application, bool bind = true)
45
54
}
46
55
47
56
// Navigation events
48
- application . PageAppearing += OnApplicationOnPageAppearing ;
49
- application . PageDisappearing += OnApplicationOnPageDisappearing ;
50
57
application . ModalPushed += OnApplicationOnModalPushed ;
51
58
application . ModalPopped += OnApplicationOnModalPopped ;
52
59
@@ -62,8 +69,6 @@ public void HandleApplicationEvents(Application application, bool bind = true)
62
69
HandleElementEvents ( application , bind : false ) ;
63
70
64
71
// Navigation events
65
- application . PageAppearing -= OnApplicationOnPageAppearing ;
66
- application . PageDisappearing -= OnApplicationOnPageDisappearing ;
67
72
application . ModalPushed -= OnApplicationOnModalPushed ;
68
73
application . ModalPopped -= OnApplicationOnModalPopped ;
69
74
0 commit comments