Arctic Vowel
Arctic Vowel

Reputation: 1522

Get Source URI of Image from code behind

I have an Image declared and Source specified in XAML with this code -

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

Is there a way I can access this source URI in the code-behind using only the name of the instance ? I've tried image.Source but that only gives the BitmapImage that the image uses and not the URI.

Upvotes: 2

Views: 527

Answers (1)

Carbine
Carbine

Reputation: 7903

Use the UriSource property of the BitmapImage you get from the source.

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

Upvotes: 1

Related Questions