简体   繁体   中英

Get image uri from Source

How do I get the image url? My xaml is:

<toolkit:HubTile Name="Demo" Title="Demo" Source="demo\0.png"  Margin="15" Tap="Demo_Tap"/>

and in c# I try to get the url from the sender (because I have a lot of entry's in the same tap) my c# so far

((Microsoft.Phone.Controls.HubTile)(sender)).Source 

and I get errors

what I need rests inside

System.Windows.Media.Imaging.BitmapImage m_string;

but how do I access that?

如果SourceBitmapImage ,则可以将发送方源BitmapImageBitmapImage

(((Microsoft.Phone.Controls.HubTile)(sender)).Source as BitmapImage).UriSource.OriginalString

Source

Source is a dependency property of type ImageSource. It gets or sets the image source of the HubTile control.

Are you casting to an ImageSource when getting the value? Also, it would help if you displayed the error message.

Update

Per your update, casting to a BitmapImage and getting the UriSource would probably get you what you want:

(BitmapImage).UriSource

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM