从后面的代码中获取图像的源 URI

Get Source URI of Image from code behind

我在 XAML 中使用此代码 -

声明了 Image 并指定了 Source
<Image x:Name="imgSomeFile" Source="Assets/someFile.png"/>

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

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

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