Bon,
tout est dans le titre....
j'ai un contrôle pivot et une ApplicationBar dont je souhaites activé ou pas certains boutons lorsque les pivots item change !
Donc pour l'ApplicationBar j'ai ça:
Et dans mon contrôle pivot sur l'évènnement j'ai ça:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <phone:PhoneApplicationPage.ApplicationBar> <shell:ApplicationBar x:Name="ApplicationBarMain" IsVisible="True" IsMenuEnabled="True"> <shell:ApplicationBarIconButton x:Name="ButtonSurveysSave" Click="ButtonSurveysSave_Click" IconUri="/Resources/Icons/ApplicationBar.Save.png" Text="Enregistrer"/> <shell:ApplicationBarIconButton x:Name="ButtonSurveysEdit" Click="ButtonSurveysEdit_Click" IconUri="/Resources/Icons/ApplicationBar.Edit.png" Text="Editer" /> <shell:ApplicationBarIconButton x:Name="ButtonSurveysDelete" Click="ButtonSurveysDelete_Click" IconUri="/Resources/Icons/ApplicationBar.Delete.png" Text="Supprimer" /> <shell:ApplicationBarIconButton x:Name="ButtonAbout" Click="ButtonAbout_Click" IconUri="/Resources/Icons/ApplicationBar.About.png" Text="A propos"/> </shell:ApplicationBar> </phone:PhoneApplicationPage.ApplicationBar>
Donc j'ai ajouté une clause sur chaque bouton car en fait ils sont à null et donc n'existe pas !!!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 private void Pivot_LoadedPivotItem(object sender, PivotItemEventArgs e) { switch (e.Item.Name) { case "PivotItemHome": if (ButtonSurveysDelete != null) { ButtonSurveysDelete.IsEnabled = true; } if (ButtonSurveysEdit != null) { ButtonSurveysEdit.IsEnabled = false; } if (ButtonSurveysSave != null) { ButtonSurveysSave.IsEnabled = false; } break; case "PivotItemSurveysAdd": if (ButtonSurveysDelete != null) { ButtonSurveysDelete.IsEnabled = false; } if (ButtonSurveysEdit != null) { ButtonSurveysEdit.IsEnabled = false; } if (ButtonSurveysSave != null) { ButtonSurveysSave.IsEnabled = true; } break; case "PivotItemStatistics": break; default: break; } }
Alors puisqu'il n'existe pas comment peut on les utiliser............
Merci
Partager