Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I add a behavior to ApplicationBarIconButton in C#?
    text
    copied!<p>I am attempting to add items to an application bar with behavoirs.</p> <p>In xaml they look like:</p> <pre><code>&lt;phone:PhoneApplicationPage.ApplicationBar&gt; &lt;shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"&gt; &lt;shell:ApplicationBarIconButton x:Name="Save" IconUri="/resources/icons/appbar.check.rest.png" Text="Save" /&gt; &lt;shell:ApplicationBarIconButton x:Name="Cancel" IconUri="/resources/icons/appbar.cancel.rest.png" Text="Cancel" /&gt; &lt;/shell:ApplicationBar&gt; &lt;/phone:PhoneApplicationPage.ApplicationBar&gt; &lt;i:Interaction.Behaviors&gt; &lt;Behaviors:ApplicationBarIconButtonCommand TextKey="Save" CommandBinding="{Binding SaveEventSetupCommand}" /&gt; &lt;Behaviors:ApplicationBarIconButtonCommand TextKey="Cancel" CommandBinding="{Binding CancelEventSetupCommand}" /&gt; &lt;/i:Interaction.Behaviors&gt; </code></pre> <p>For multi language support I need to add something like:</p> <pre><code>Text="{Binding Path=Localizedresources.lblCourse, Source={StaticResource LocalizedStrings}}" </code></pre> <p>to each button. It would appear that this cannot be done in xaml, hence the use of code.</p> <p>The button is added in this code:</p> <pre><code>ApplicationBarIconButton appBarSaveButton = new ApplicationBarIconButton( new Uri("/resources/icons/appbar.check.rest.png", UriKind.Relative)) { Text = "Test" }; ApplicationBar.Buttons.Add(appBarSaveButton); </code></pre> <p>I just can't figure how to add the behavior. This is my start point:</p> <pre><code>WP7Contrib.View.Controls.Behaviors.ApplicationBarIconButtonCommand ibc = new WP7Contrib.View.Controls.Behaviors.ApplicationBarIconButtonCommand { TextKey = "Test" }; </code></pre> <p>Basically I am looking for a working sample if anyone can oblige.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload