Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately you cannot bind (use staticresource) to ApplicationBarIconButton. It is not a Silverlight control, it is just a wrapper object for a low level interop with the Windows Phone 7 OS. So it cannot be databinded.</p> <p>I could suggest two options to do that.</p> <p>First and the easyer one: You can manipulate it from code-behind. Here you can acces your resourcedictionary too, it is just a working sample from me (with the hard-coded string).</p> <pre><code>void MainPage_Loaded(object sender, RoutedEventArgs e) { //this.AppBarButton1.IconUri = new Uri("/Images/dark/Timing.png"); //WRONG NullReferenceException var button1 = this.ApplicationBar.Buttons[1] as ApplicationBarIconButton; button1.IconUri = new Uri(@"./Images/dark/Timing.png", UriKind.Relative); } </code></pre> <p>The second one requeres more coding: You could implement your own ApplicationBarIconButton. You need to derive from <strong>ApplicationBarMenuItem</strong> and implement <strong>Microsoft.Phone.Shell.IApplicationBarIconButton</strong>. After that you can add a DependencyProperty to your own control like:</p> <pre><code>public Uri IconUri { get { return (Uri)GetValue(IconUriProperty); } set { SetValue(IconUriProperty, value); } } // Using a DependencyProperty as the backing store for IconUri. This enables animation, styling, binding, etc... public static readonly DependencyProperty IconUriProperty = DependencyProperty.Register( "IconUri", typeof(Uri), typeof(ApplicationBarIconButton), new PropertyMetadata(default(Uri), (d, e) =&gt; ((ApplicationBarIconButton)d).IconUriChanged((Uri)e.NewValue))); private void IconUriChanged(Uri iconUri) { var button = SysAppBarMenuItem as Microsoft.Phone.Shell.IApplicationBarIconButton; button.IconUri = iconUri; } </code></pre> <p>I hope it could help you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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