Reputation: 863
Dynamic icons in ApplicationBar
It's possible to have dynamic icons in ApplicationBar with dynamic images loaded from url? I tried this:
xaml:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
cs:
var myIcon = ApplicationBar.Buttons[1] as ApplicationBarIconButton;
myIcon.IconUri = new Uri(iconImageUrl, UriKind.Absolute);
I'm getting error: Path cannot be absolute.
Upvotes: 1
Views: 2092
Reputation: 11
I think the best idea is to save your image in isolated storage and call it with UriKind.Relative.
Upvotes: 1
Reputation: 15004
Chage the second parametr to UriKind.Relative if the uri is relative - looks like this one:
"/Images/icon.png"
Upvotes: 3