FrameworkElement.BaseUri 속성

정의

XAML 로드 시 XAML 생성 개체의 기본 URI(Uniform Resource Identifier)를 나타내는 URI(Uniform Resource Identifier)를 가져옵니다. 이 속성은 런타임에 URI(Uniform Resource Identifier) 확인에 유용합니다.

public:
 property Uri ^ BaseUri { Uri ^ get(); };
Uri BaseUri();
public System.Uri BaseUri { get; }
var uri = frameworkElement.baseUri;
Public ReadOnly Property BaseUri As Uri

속성 값

XAML 로드 시 개체의 기본 URI(Uniform Resource Identifier)입니다.

예제

이 예제에서는 이미지 원본을 백업/기본값으로 다시 설정하는 이벤트 처리기에서 BaseUri를 사용합니다. BaseUri는 BitmapImage 생성자 호출에 사용되는 새 URI(Uniform Resource Identifier)의 "경로" 부분에 사용되며, 나머지 URI(Uniform Resource Identifier)는 앱이 리소스에 있는 이미지 파일을 가리킵니다. 컨텍스트에서 이 코드를 보려면 CameraCaptureUI 샘플을 참조하세요.

void SDKSample::Page::Reset_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
    rootPage->NotifyUser("The photo will be shown here.", NotifyType::StatusMessage); 
    ResetButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed; 
    CapturedPhoto->Source = ref new BitmapImage(ref new Windows::Foundation::Uri(BaseUri->AbsoluteUri, "Assets/placeholder-sdk.png")); 
     // Remove file from Application Data 
    appSettings->Remove("capturedPhoto"); 
}
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 
    appSettings.Remove(photoKey);
}
Private Sub Reset_Click(sender As Object, e As RoutedEventArgs)
    ResetButton.Visibility = Visibility.Collapsed
    CapturedPhoto.Source = New BitmapImage(New Uri(Me.BaseUri, "Assets/placeholder-sdk.png"))
    ' Clear file path in Application Data 
    appSettings.Remove(photoKey)
End Sub

설명

XAML 파서는 페이지의 개체 컨텍스트에 따라 리소스에 대한 참조를 평가할 수 있으므로 URI(Uniform Resource Identifier) 속성에서 부분 경로로 보이는 것을 평가할 수 있습니다. 런타임 코드의 경우 URI(Uniform Resource Identifier) 형식에 대한 정의 규칙은 부분 경로를 허용하지 않습니다. 런타임에 XAML 페이지를 구문 분석하여 만든 개체의 scope BaseUri를 사용하여 URI(Uniform Resource Identifier)의 "경로" 부분을 구문 분석한 다음, 특정 리소스 참조를 사용하여 URI(Uniform Resource Identifier)를 완료할 수 있습니다.

이전 버전에 대한 참고 사항

Windows 8 Windows 8 스타일 또는 템플릿 파트에서 BaseUri가 반환한 URI는 개체를 만든 XAML 파일에 특정된 값이 아닌 프로젝트 기본값을 나타내는 값을 반환할 수 있습니다. BaseUri 동작이 Windows 8.1 시작하여 수정되었습니다. 그러나 BaseUri의 이전 동작에 의존하여 XAML 컴퍼지션 또는 리소스 조회를 변경한 경우 BaseUri를 호출하는 코드 영역을 검사할 수 있습니다. 앱이 Windows 8.1 대해 다시 컴파일될 때 리소스 또는 지역화 정보를 찾는 데 사용하는 결합된 URI(Uniform Resource Identifier)가 예상대로 작동하는지 확인합니다. Windows 8용으로 컴파일되었지만 Windows 8.1에서 실행하는 앱은 Windows 8 동작을 계속 사용합니다.

적용 대상