简体   繁体   English

从源获取图像uri

[英]Get image uri from Source

How do I get the image url? 如何获取图片网址? My xaml is: 我的xaml是:

<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 到目前为止,在C#中,我尝试从发件人获取url(因为同一输入中有很多条目)

((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. Source是类型为ImageSource的依赖项属性。 It gets or sets the image source of the HubTile control. 它获取或设置HubTile控件的图像源。

Are you casting to an ImageSource when getting the value? 获取值时是否要投射到ImageSource? 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可能会为您提供所需的内容:

(BitmapImage).UriSource

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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