public static DependencyPropertyKey RegisterReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata metadata = null, ValidateValueCallback validateValueCallback = null) { DependencyPropertyHashKey hashKey = new DependencyPropertyHashKey(ownerType, name); DependencyPropertyKey readOnlyKey = new DependencyPropertyKey(Register(hashKey, propertyType, metadata, validateValueCallback, false, true)); registeredReadOnlyPropertiesKey.Add(hashKey, readOnlyKey); return(readOnlyKey); }
public static RoutedEvent RegisterRoutedEvent(string name, RoutingStrategy routingStrategy, Type handlerType, Type ownerType) { RoutedEventHashKey key = new RoutedEventHashKey(ownerType, name); if (registeredEvents.ContainsKey(key)) { throw new Granular.Exception("RoutedEvent {0}.{1} is already registered", ownerType.Name, name); } RoutedEvent routedEvent = new RoutedEvent(name, routingStrategy, handlerType, ownerType); registeredEvents.Add(key, routedEvent); return(routedEvent); }
public object GetValue(DependencyProperty dependencyProperty) { IDependencyPropertyValueEntry entry; if (!entries.TryGetValue(dependencyProperty, out entry)) { PropertyMetadata propertyMetadata = dependencyProperty.GetMetadata(GetType()); // no need to create a new entry if the value is not inherited or coerced if (!propertyMetadata.Inherits && (propertyMetadata.CoerceValueCallback == null || !dependencyProperty.IsAttached && !dependencyProperty.IsContainedBy(GetType()))) { return(propertyMetadata.DefaultValue); } entry = CreateDependencyPropertyValueEntry(dependencyProperty, propertyMetadata); entries.Add(dependencyProperty, entry); } return(entry.Value); }
private IDependencyPropertyValueEntry GetInitializedReadOnlyValueEntry(DependencyProperty dependencyProperty) { IDependencyPropertyValueEntry readOnlyEntry; if (readOnlyEntries.TryGetValue(dependencyProperty, out readOnlyEntry)) { return(readOnlyEntry); } readOnlyEntry = new ReadOnlyDependencyPropertyValueEntry(GetInitializedValueEntry(dependencyProperty)); readOnlyEntries.Add(dependencyProperty, readOnlyEntry); return(readOnlyEntry); }
private static void AddRegisteredProperty(DependencyPropertyHashKey key, DependencyProperty dependencyProperty) { VerifyNotRegistered(key, dependencyProperty); registeredProperties.Add(key, dependencyProperty); }