@@ -9,28 +9,37 @@ public MainPage()
99 InitializeComponent ( ) ;
1010 }
1111
12- private void PdfViewer_FormFieldValueChanged ( object sender , FormFieldValueChangedEventArgs e )
12+ private async void PdfViewer_FormFieldValueChanged ( object sender , FormFieldValueChangedEventArgs e )
1313 {
14- if ( Application . Current != null )
15- Application . Current . Windows [ 0 ] . Page ? . DisplayAlert ( "PDF Edited" , $ "{ e . FormField } value is changed.", "OK" ) ;
14+ var page = Application . Current ? . Windows ? . FirstOrDefault ( ) ? . Page ;
15+ if ( page is null )
16+ return ;
17+
18+ await page . DisplayAlertAsync ( "PDF Edited" , $ "{ e . FormField } value is changed.", "OK" ) ;
1619 }
1720
18- private void PdfViewer_AnnotationAdded ( object sender , AnnotationEventArgs e )
21+ private async void PdfViewer_AnnotationAdded ( object sender , AnnotationEventArgs e )
1922 {
20- if ( Application . Current != null )
21- Application . Current . Windows [ 0 ] . Page ? . DisplayAlert ( "PDF Edited" , "Annotation is added." , "OK" ) ;
23+ var page = Application . Current ? . Windows ? . FirstOrDefault ( ) ? . Page ;
24+ if ( page is null )
25+ return ;
26+ await page . DisplayAlertAsync ( "PDF Edited" , "Annotation is added." , "OK" ) ;
2227 }
2328
24- private void PdfViewer_AnnotationEdited ( object sender , AnnotationEventArgs e )
29+ private async void PdfViewer_AnnotationEdited ( object sender , AnnotationEventArgs e )
2530 {
26- if ( Application . Current != null )
27- Application . Current . Windows [ 0 ] . Page ? . DisplayAlert ( "PDF Edited" , $ "Annotation is edited.", "OK" ) ;
31+ var page = Application . Current ? . Windows ? . FirstOrDefault ( ) ? . Page ;
32+ if ( page is null )
33+ return ;
34+ await page . DisplayAlertAsync ( "PDF Edited" , $ "Annotation is edited.", "OK" ) ;
2835 }
2936
30- private void PdfViewer_AnnotationRemoved ( object sender , AnnotationEventArgs e )
37+ private async void PdfViewer_AnnotationRemoved ( object sender , AnnotationEventArgs e )
3138 {
32- if ( Application . Current != null )
33- Application . Current . Windows [ 0 ] . Page ? . DisplayAlert ( "PDF Edited" , $ "Annotation is removed.", "OK" ) ;
39+ var page = Application . Current ? . Windows ? . FirstOrDefault ( ) ? . Page ;
40+ if ( page is null )
41+ return ;
42+ await page . DisplayAlertAsync ( "PDF Edited" , $ "Annotation is removed.", "OK" ) ;
3443 }
3544 }
3645}
0 commit comments