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.
如果uri是相对的,则将第二个参数转换为UriKind.Relative - 看起来像这样:
"/Images/icon.png"
我认为最好的想法是将您的图像保存在独立存储中并使用UriKind.Relative进行调用。
完整设置appbar IconUri,请参阅:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.