Thursday 15 August 2013

c# - WPF - Uri to content images -



c# - WPF - Uri to content images -

i spent 1 hr on browsing net , trying find way how load uri content image , create bitmapimage.

that have:

{ uri x = new uri("/images/appbar.chevron.up.png", urikind.relative); bitmapimage bi = new bitmapimage(x); homecoming x; }

images in solution explorer under project:

and each image have build action content

i'm recieving the given system.uri cannot converted windows.foundation.uri. please see http://go.microsoft.com/fwlink/?linkid=215849 details. on creating bitmapimage, debugger showes me uri created:

please tell me, how can load selected image?

as noted, load image app bundle you'll utilize ms-appx protocol. see uri schemes documentation on msdn

uri x = new uri("ms-appx:///images/appbar.chevron.up.png"); bitmapimage bi = new bitmapimage(x);

then you'll want homecoming bitmapimage rather uri caller:

return bi; // not: homecoming x;

or set on image control. bitmapimage info , doesn't show on own.

img.setsource(bi);

where img created in xaml:

guessing names of images trying set them in appbar buttons. can utilize segoe ui symbol font instead of loading images:

<appbarbutton> <appbarbutton.icon> <fonticon fontfamily="segoe ui symbol" glyph="&#57361;"/> </appbarbutton.icon> </appbarbutton> <appbarbutton> <appbarbutton.icon> <fonticon fontfamily="segoe ui symbol" glyph="&#57360;"/> </appbarbutton.icon> </appbarbutton>

or if want set appbarbuttons images in xaml:

<appbarbutton> <appbarbutton.icon> <bitmapicon urisource="images/appbar.chevron.up.png"/> </appbarbutton.icon> </appbarbutton> <appbarbutton> <appbarbutton.icon> <bitmapicon urisource="images/appbar.chevron.down.png"/> </appbarbutton.icon> </appbarbutton>

c# image windows-runtime

No comments:

Post a Comment