StaticResourceExtension.ProvideValue(IServiceProvider) 方法

定义

返回一个应在应用了此扩展的属性上设置的对象。Returns an object that should be set on the property where this extension is applied. 对于 StaticResourceExtension,这是在资源字典中查找的对象,其中要查找的对象由 ResourceKey 标识。For StaticResourceExtension, this is the object found in a resource dictionary, where the object to find is identified by the ResourceKey.

public:
 override System::Object ^ ProvideValue(IServiceProvider ^ serviceProvider);
public override object ProvideValue (IServiceProvider serviceProvider);
override this.ProvideValue : IServiceProvider -> obj
Public Overrides Function ProvideValue (serviceProvider As IServiceProvider) As Object

参数

serviceProvider
IServiceProvider

可为标记扩展提供服务的对象。Object that can provide services for the markup extension.

返回

Object

要在计算标记扩展提供的值的属性上设置的对象值。The object value to set on the property where the markup extension provided value is evaluated.

例外

serviceProvidernull,或未能实现所需服务。serviceProvider was null, or failed to implement a required service.

注解

此方法支持 WPFWPF XAML 处理器实现,不应直接调用。This method supports WPFWPF XAML processor implementation, and is not intended to be called directly. XAML 处理器实现使用此方法 StaticResource 在对象创建过程中正确处理扩展值。The XAML processor implementation uses this method for proper handling of StaticResource extension values during object creation.

要设置的属性可由 PropertyInfo (标准属性) 或 DependencyProperty (依赖属性) 标识。The property to be set can be identified by a PropertyInfo (standard property) or DependencyProperty (dependency property).

此实现依赖于 XAML 相关的服务,基于传递的 serviceProviderThis implementation relies on XAML-related services based on the passed serviceProvider. 不得为 nullIt must not be null. .NET Framework 4.NET Framework 4 实现中,以下是服务上下文所需的服务:In the .NET Framework 4.NET Framework 4 implementation, the following are required services from service context:

如果这些服务中有任何服务丢失,则标记扩展的使用会引发异常。If any of these services are missing, usage of the markup extension throws an exception.

适用于