internal void StyleSetterValueChanged(object sender, RoutedEventArgs e) { Setter setter = (Setter)sender; if (setter.Property != null) // Note: it can be null for example in the XAML text editor during design time, because the "DependencyPropertyConverter" class returns "null". { INTERNAL_PropertyStorage storage = INTERNAL_PropertyStore.GetStorageOrCreateNewIfNotExists(this, setter.Property); HashSet2 <Style> stylesAlreadyVisited = new HashSet2 <Style>(); // Note: "stylesAlreadyVisited" is here to prevent an infinite recursion. INTERNAL_PropertyStore.SetLocalStyleValue(storage, Style.GetActiveValue(setter.Property, stylesAlreadyVisited)); } }
public void SetAnimationValue(DependencyProperty dependencyProperty, object value) { if (dependencyProperty == null) { throw new ArgumentNullException("No property specified"); } var storage = INTERNAL_PropertyStore.GetStorageOrCreateNewIfNotExists(this, dependencyProperty); INTERNAL_PropertyStore.SetSpecificValue(storage, KindOfValue.Animated, value); }
/// <summary> /// Sets the local value of a dependency property on a DependencyObject while not overriding a hypothetical Binding (example: when the user writes in a TextBox with a two way Binding on its Text property). /// </summary> /// <param name="dependencyProperty">The identifier of the dependency property to set.</param> /// <param name="value">The new local value.</param> public void SetLocalValue(DependencyProperty dependencyProperty, object value) { #if PERFSTAT var t = Performance.now(); #endif var storage = INTERNAL_PropertyStore.GetStorageOrCreateNewIfNotExists(this, dependencyProperty); #if PERFSTAT Performance.Counter("DependencyObject.SetLocalValue", t); #endif INTERNAL_PropertyStore.SetSpecificValue(storage, KindOfValue.Local, value); }
private static void Style_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { var frameworkElement = (FrameworkElement)d; if (!frameworkElement.INTERNAL_DoNotApplyStyle) { Style newStyle = (Style)e.NewValue; Style oldStyle = (Style)e.OldValue; Dictionary <DependencyProperty, Setter> oldStyleDictionary = new Dictionary <DependencyProperty, Setter>(); if (oldStyle != null) { oldStyleDictionary = oldStyle.GetDictionaryOfSettersFromStyle(); } Dictionary <DependencyProperty, Setter> newStyleDictionary = new Dictionary <DependencyProperty, Setter>(); if (newStyle != null) { newStyleDictionary = newStyle.GetDictionaryOfSettersFromStyle(); } #if PERFSTAT var t0 = Performance.now(); #endif frameworkElement.RecursivelyUnregisterFromStyleChangedEvents(oldStyle); #if PERFSTAT Performance.Counter("RecursivelyUnregisterFromStyleChangedEvents", t0); #endif #if PERFSTAT var t1 = Performance.now(); #endif frameworkElement.RecursivelyRegisterToStyleChangedEvents(newStyle); #if PERFSTAT Performance.Counter("RecursivelyRegisterToStyleChangedEvents", t1); #endif foreach (Setter oldSetter in #if BRIDGE INTERNAL_BridgeWorkarounds.GetDictionaryValues_SimulatorCompatible(oldStyleDictionary) #else oldStyleDictionary.Values #endif ) { if (oldSetter.Property != null) // Note: it can be null for example in the XAML text editor during design time, because the "DependencyPropertyConverter" class returns "null". { if (!newStyleDictionary.ContainsKey(oldSetter.Property)) { INTERNAL_PropertyStorage storage = INTERNAL_PropertyStore.GetStorageIfExists(d, oldSetter.Property); if (storage != null) { INTERNAL_PropertyStore.ResetLocalStyleValue(storage); } } } // Reset the information that tells which Style the Setter belongs to (this is used so that when the Value of the Setter changes, the Setter can notify its parent Style): oldSetter.INTERNAL_ParentStyle = null; } foreach (Setter newSetter in #if BRIDGE INTERNAL_BridgeWorkarounds.GetDictionaryValues_SimulatorCompatible(newStyleDictionary) #else newStyleDictionary.Values #endif ) { if (newSetter.Property != null) // Note: it can be null for example in the XAML text editor during design time, because the "DependencyPropertyConverter" class returns "null". { if (!oldStyleDictionary.ContainsKey(newSetter.Property) || oldStyleDictionary[newSetter.Property] != newSetter.Value) { INTERNAL_PropertyStorage storage = INTERNAL_PropertyStore.GetStorageOrCreateNewIfNotExists(frameworkElement, newSetter.Property); INTERNAL_PropertyStore.SetLocalStyleValue(storage, newSetter.Value); } } // Tell the setter which Style it belongs to, so that when the Value of the Setter changes, it can notify the parent Style: newSetter.INTERNAL_ParentStyle = newStyle; } } }
public void CoerceCurrentValue(DependencyProperty dependencyProperty, PropertyMetadata propertyMetadata) { var storage = INTERNAL_PropertyStore.GetStorageOrCreateNewIfNotExists(this, dependencyProperty); INTERNAL_PropertyStore.CoerceCurrentValue(storage); }