/// <summary> /// Initializes a new instance of the <see cref="StyleItem"/> class. /// </summary> public StyleItem(Style style, FrameworkElement source, string name, string location, StyleScope scope) { Style = style; Name = name; Location = location; Scope = scope; // Setters foreach (Setter setter in style.Setters) { if (setter.Property.Name == "OverridesDefaultStyle" && setter.Value.ToString().ToLower() == "true") { OverridesDefaultStyle = true; } _setterItems.Add(new SetterItem(setter, source)); } // Triggers foreach (var trigger in style.Triggers) { _triggerItems.Add(TriggerItemFactory.GetTriggerItem(trigger, source, TriggerSource.Style)); } // Ressources foreach (var resource in ResourceHelper.GetResourcesRecursively <object>(style.Resources)) { _resourceItems.Add(ResourceItemFactory.CreateResourceItem(resource.Key, resource.Owner, source, ResourceScope.Style)); } GlobalIndex = StyleHelper.GetGlobalIndex(style); }
/// <summary> /// Initializes a new instance of the <see cref="SetterItem"/> class. /// </summary> public SetterItem(SetterBase setterBase, FrameworkElement source) { var setter = setterBase as Setter; if (setter != null) { Property = setter.Property.Name; if (setter.Value is DynamicResourceExtension) { var resourceKey = ((DynamicResourceExtension)setter.Value).ResourceKey; Value = ResourceItemFactory.CreateResourceItem(resourceKey, source.Resources, source, ResourceScope.Style); } else if (setter.Value != null) { Value = setter.Value; } else { Value = "null"; } } }