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 信息调用该模式, 或存储从根元素。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.exception 程序集。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 , 类可以使用为属性提供的相对 URI ( Page.FontFamily例如), 如果IUriContextITypeDescriptorContext输入中作为服务提供。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 值 (然后进行修改NavigateUri)。As an example of the element case, Hyperlink implements IUriContext so that it can pass through base URI values when parsed, which then modifies NavigateUri.

属性

BaseUri

获取或设置当前应用程序上下文的基 URI。Gets or sets the base URI of the current application context.

适用于

另请参阅