【问题标题】:Get Source URI of Image from code behind从后面的代码中获取图像的源 URI
【发布时间】:2016-05-26 18:24:08
【问题描述】:

我在 XAML 中使用此代码声明了 Image 并指定了 Source -

<Image x:Name="imgSomeFile" Source="Assets/someFile.png"/>

有没有一种方法可以仅使用实例名称在代码隐藏中访问此源 URI?我试过image.Source,但这只给出了图像使用的BitmapImage,而不是URI。

【问题讨论】:

    标签: c# windows-runtime windows-store-apps microsoft-metro


    【解决方案1】:

    使用您从源获得的BitmapImageUriSource 属性。

    ((imgSomeFile).Source as BitmapImage).UriSource.OriginalString
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-07
      • 1970-01-01
      • 2010-10-20
      • 1970-01-01
      • 2017-06-30
      • 2011-10-12
      相关资源
      最近更新 更多