IUriContext 介面


表示可以使用應用程式內容來解析所提供相對 URI 為絕對 URI 的服務。Represents a service that can use application context to resolve a provided relative URI to an absolute URI.

public interface class IUriContext
public interface IUriContext
type IUriContext = interface
Public Interface IUriContext


IUriContext實作為服務可讓型別轉換器使用可完成 URI 型別屬性的應用程式特定內容。IUriContext implemented as a service enables type converters to use an application-specific context that might be able to complete a URI-type property.

當 xaml 物件寫入器IUriContext叫用值轉換行為時, 類型轉換器和標記延伸可以在 xaml 物件寫入器所提供的服務內容上, 查詢做為服務。Type converters and markup extensions can query for IUriContext as a service on the service context that is provided by a XAML object writer, when the XAML object writer invokes value conversion behavior. 如需詳細資訊, 請參閱XAML 的類型轉換器和標記延伸適用于類型轉換器和標記延伸的服務內容。For more information, see Type Converters and Markup Extensions for XAML and Service Contexts Available to Type Converters and Markup Extensions.

IUriContext不只適用于值轉換和服務內容。IUriContext is not just for value conversion and service context. UI 元素或其他支援內含專案之類別的類別邏輯, 也IUriContext可能會將服務實作為可辨識的模式, 讓子專案可以呼叫基底 uri 資訊, 或儲存從 XAML 剖析取得的基底 uri 資訊根項目。Class logic for UI elements or other classes that support containment might also implement IUriContext services as a recognized pattern that child elements can call for base URI information, or store base URI information that is obtained from XAML parsing of the root element.

在舊版的 .NET Framework 中, 這個介面存在於 WPF 特定的元件 PresentationCore 中。In previous versions of the .NET Framework, this interface existed in the WPF-specific assembly PresentationCore. .NET Framework 4.NET Framework 4IUriContext , 位於 system.object 元件中。In .NET Framework 4.NET Framework 4, IUriContext is in the System.Xaml assembly. 如需詳細資訊,請參閱 Types Migrated from WPF to System.XamlFor more information, see Types Migrated from WPF to System.Xaml.

WPF 使用注意事項WPF Usage Notes

WPF 中存在IUriContext的範例案例。Example scenarios for IUriContext exist in WPF.

作為值轉換器的FontFamilyConverter範例, 如果IUriContextITypeDescriptorContext輸入上以服務形式提供Page.FontFamily, 則類別可以使用提供給屬性 (例如) 的相對 URI。As an example of a value converter, the FontFamilyConverter class can use a relative URI that is provided for properties such as Page.FontFamily, if IUriContext is available as a service on the ITypeDescriptorContext input.

作為元素案例的範例, Hyperlink IUriContext會執行, 讓它可以在剖析後通過基底 URI 值, 然後進行修改NavigateUriAs an example of the element case, Hyperlink implements IUriContext so that it can pass through base URI values when parsed, which then modifies NavigateUri.



取得或設定目前應用程式內容的基底 URI。Gets or sets the base URI of the current application context.