Janci
Janci

Reputation: 863

WP7 Dynamic icons in ApplicationBar

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

Answers (3)

Newred
Newred

Reputation: 729

Full setting appbar IconUri, see:

Upvotes: 0

Igor
Igor

Reputation: 11

I think the best idea is to save your image in isolated storage and call it with UriKind.Relative.

Upvotes: 1

Lukasz Madon
Lukasz Madon

Reputation: 15004

Chage the second parametr to UriKind.Relative if the uri is relative - looks like this one:

"/Images/icon.png" 

Upvotes: 3

Related Questions