Question

The following code assigns the Microphone.png image to image of button but I failed to understand the role of relative parameter in overloaded version of Uri class.

RecordButton.IconUri = new Uri(
    "/Assets/AppBar/microphone.png", UriKind.Relative);
Was it helpful?

Solution

Exemple : Relative => You should be in the same folder. Folder 1 contains one page " page 1 " and an image "X" Folder 2 contains one page " page 2 "

You are in the page 2 and you write =>

<image source="X.png" /> 

You can't do this because you are not in the correct folder but you can write "/Folder1/X.png" or "../Folder1/X.png".

Absolute => Full path like http://Abundantcode.com/image.jpg

For windows phone developpement, you have uriking.relativeorabsolute property :D

OTHER TIPS

URIKind.Relative means that you don't have a full path to the file. Absolute means that you will specify full path to the file.

I've used relative Uris with the Uri constructor

public Uri(
    Uri baseUri,
    Uri relativeUri
)

to create a fully pathed URI. There are some advantages in reducing storage overhead and you can interchange the baseUri even across protocols if I remember correctly.

Absolute URIs are characterized by a complete reference to the resource

example: http://www.contoso.com/index.html

While a relative Uri depends on a previously defined base URI

example: /index.html

Check out this UriKind.Relative

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top