/// <summary> /// Returns an absolute <see cref="Uri"/>, based on the <paramref name="dict"/>'s /// source. /// </summary> /// <param name="dict">The <see cref="ResourceDictionary"/>.</param> /// <returns> /// An absolute <see cref="Uri"/>, pointing to the <paramref name="dict"/>'s source. /// </returns> public static Uri GetAbsoluteSourceUri(this ResourceDictionary dict) { if (dict == null) { throw new ArgumentNullException(nameof(dict)); } if (dict.Source == null) { throw new ArgumentException( "The dictionaries Source property must not be null.", nameof(dict)); } if (dict.Source.IsAbsoluteUri) { return(dict.Source); } Uri baseUri = dict.GetBaseSourceUri(); if (baseUri == null) { throw new ArgumentException( "Cannot compose an absolute Uri, since no base Uri could be retrieved."); } return(new Uri(baseUri, dict.Source)); }