BaseUri property
Collapse the table of content
Expand the table of content

FrameworkElement.BaseUri property

Gets a Uniform Resource Identifier (URI) that represents the base URI for an XAML-constructed object at XAML load time. This property is useful for URI resolution at run time.


public Uri BaseUri { get; }

Property value

Type: System.Uri [.NET] | Windows::Foundation::Uri [C++]

The base URI for an object at XAML load time.


The XAML parser can evaluate references to resources based on the context of the object in a page, and can thus evaluate what appear to be partial paths in a URI property. For run-time code, the definition rules for the URI types don't permit partial paths. At run time, you can use BaseUri from the scope of an object that was created by parsing a XAML page in order to get the "path" part of a URI, and then complete the URI with a particular resource reference.

Windows 8 behavior

In Windows 8, the URI returned by BaseUri from style or template parts could return values that represented a project default rather than a value that was specific for the XAML file that created an object. The BaseUri behavior has been corrected starting with Windows 8.1. But if you relied on the previous behavior of BaseUri and changed your XAML compositions or resource lookups because of it, you might want to examine the areas of your code that make BaseUri calls. Verify that the combined URIs you use for finding resources or localization info work as expected when your app is recompiled for Windows 8.1. Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.


This example uses BaseUri in an event handler that resets an image source to a backup/default. BaseUri is used for the "path" part of a new URI that is used for a BitmapImage constructor call, the rest of the URI points to an image file that the app has in its resources. To see this code in context, see the CameraCaptureUI sample.

private void Reset_Click(object sender, RoutedEventArgs e)
    ResetButton.Visibility = Visibility.Collapsed;
    CapturedPhoto.Source = new BitmapImage(new Uri(this.BaseUri, "Assets/placeholder-sdk.png"));

    // Clear file path in Application Data 

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::UI::Xaml [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]


Windows::UI::Xaml [C++]



See also




© 2017 Microsoft