System.Windows.DynamicResourceExtension.ProvideValue C# (CSharp) Method

ProvideValue() public method

Return an object that should be set on the targetObject's targetProperty for this markup extension. For DynamicResourceExtension, this is the object found in a resource dictionary in the current parent chain that is keyed by ResourceKey
public ProvideValue ( IServiceProvider serviceProvider ) : object
serviceProvider IServiceProvider
return object
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            if (ResourceKey == null)
            {
                throw new InvalidOperationException(SR.Get(SRID.MarkupExtensionResourceKey));
            }

            if (serviceProvider != null)
            {
                // DynamicResourceExtensions are not allowed On CLR props except for Setter,Trigger,Condition (bugs 1183373,1572537)

                DependencyObject targetDependencyObject;
                DependencyProperty targetDependencyProperty;
                Helper.CheckCanReceiveMarkupExtension(this, serviceProvider, out targetDependencyObject, out targetDependencyProperty);
            }

            return new ResourceReferenceExpression(ResourceKey);
        }