开发者

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] a开发者_开发知识库s ApplicationBarIconButton;
myIcon.IconUri = new Uri(iconImageUrl, UriKind.Absolute);

I'm getting error: Path cannot be absolute.


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

"/Images/icon.png" 


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


Full setting appbar IconUri, see:

WP7 Dynamic icons in ApplicationBar

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜