Je tente d'ajouter des éléments à une barre d'applications avec des comportements.Comment ajouter un comportement à ApplicationBarIconButton en C#?
En XAML ils ressemblent:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True"
IsMenuEnabled="True">
<shell:ApplicationBarIconButton x:Name="Save"
IconUri="/resources/icons/appbar.check.rest.png"
Text="Save" />
<shell:ApplicationBarIconButton x:Name="Cancel"
IconUri="/resources/icons/appbar.cancel.rest.png"
Text="Cancel" />
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<i:Interaction.Behaviors>
<Behaviors:ApplicationBarIconButtonCommand TextKey="Save"
CommandBinding="{Binding SaveEventSetupCommand}" />
<Behaviors:ApplicationBarIconButtonCommand TextKey="Cancel"
CommandBinding="{Binding CancelEventSetupCommand}" />
</i:Interaction.Behaviors>
Pour support multi-langue je dois ajouter quelque chose comme:
Text="{Binding Path=Localizedresources.lblCourse, Source={StaticResource LocalizedStrings}}"
à chaque bouton. Il semblerait que cela ne puisse pas être fait dans xaml, d'où l'utilisation du code.
Le bouton est ajouté dans ce code:
ApplicationBarIconButton appBarSaveButton = new ApplicationBarIconButton(
new Uri("/resources/icons/appbar.check.rest.png", UriKind.Relative))
{ Text = "Test" };
ApplicationBar.Buttons.Add(appBarSaveButton);
Je ne peux pas comprendre comment ajouter le comportement. Ceci est mon point de départ:
WP7Contrib.View.Controls.Behaviors.ApplicationBarIconButtonCommand
ibc = new WP7Contrib.View.Controls.Behaviors.ApplicationBarIconButtonCommand
{ TextKey = "Test" };
Fondamentalement, je suis à la recherche d'un échantillon de travail si quelqu'un peut obliger.
Merci
Quel genre de comportement? Je suis afriad cela ne peut pas être fait, depuis ApplicationBar n'est pas le contrôle Silverlight. –