/// <summary> /// Applies a style to the element. /// </summary> /// <param name="style">The style which is being applied.</param> /// <param name="selector">The selector which caused the style to be applied.</param> /// <param name="navigationExpression">The navigation expression associated with the style.</param> /// <param name="dprop">A <see cref="DependencyProperty"/> that identifies the dependency property which is being styled.</param> protected internal virtual void ApplyStyle(UvssRule style, UvssSelector selector, NavigationExpression?navigationExpression, DependencyProperty dprop) { if (dprop != null) { dprop.ApplyStyle(this, style); } }
/// <summary> /// Applies the specified style to the dependency property. /// </summary> /// <param name="dobj">The dependency object on which to set the style.</param> /// <param name="style">The style to set on this dependency property.</param> /// <param name="provider">An object that supplies culture-specific formatting information.</param> internal void ApplyStyle(DependencyObject dobj, UvssRule style, IFormatProvider provider) { if (styleSetter == null) { throw new InvalidOperationException(PresentationStrings.DependencyPropertyIsReadOnly.Format(Name)); } styleSetter(dobj, style, provider); }
/// <summary> /// Applies the specified style to the dependency property. /// </summary> /// <param name="dobj">The dependency object on which to set the style.</param> /// <param name="style">The style to set on this dependency property.</param> internal void ApplyStyle(DependencyObject dobj, UvssRule style) { if (styleSetter == null) { throw new InvalidOperationException(PresentationStrings.DependencyPropertyIsReadOnly.Format(Name)); } styleSetter(dobj, style, CultureInfo.InvariantCulture); }
/// <summary> /// Converts a string to a value to be applied to a styled dependency property. /// </summary> /// <param name="style">The style to resolve to a value.</param> /// <param name="type">The type of object to create.</param> /// <param name="provider">An object that supplies culture-specific formatting information.</param> /// <returns>The object that was created.</returns> private static Object ResolveStyledValue(UvssRule style, Type type, IFormatProvider provider) { if (style.CachedResolvedValue != null && style.CachedResolvedValue.GetType() == type) { return(style.CachedResolvedValue); } var value = style.Value.Trim(); if (value == "null") { return(type.IsValueType ? Activator.CreateInstance(type) : null); } var resolvedValue = ObjectResolver.FromString(value, type, provider, true); style.CachedResolvedValue = resolvedValue; return(resolvedValue); }
/// <inheritdoc/> protected internal sealed override void ApplyStyle(UvssRule style, UvssSelector selector, NavigationExpression?navigationExpression, DependencyProperty dp) { base.ApplyStyle(style, selector, navigationExpression, dp); }