Example #1
0
        public void Apply(/*VisualElement*/ BaseHandle styleable, bool inheriting = false)
        {
            if (styleable == null)
            {
                throw new ArgumentNullException(nameof(styleable));
            }

            foreach (var decl in Declarations)
            {
                var property = ((IStylable)styleable).GetProperty(decl.Key, inheriting);
                if (property == null)
                {
                    continue;
                }
                if (string.Equals(decl.Value, "initial", StringComparison.OrdinalIgnoreCase))
                {
                    styleable.ClearValue(property, fromStyle: true);
                }
                else
                {
                    object value;
                    if (!convertedValues.TryGetValue(decl, out value))
                    {
                        convertedValues[decl] = (value = Convert(styleable, decl.Value, property));
                    }
                    styleable.SetValue(property, value, fromStyle: true);
                }
            }

            foreach (var child in styleable.LogicalChildrenInternal)
            {
                var ve = child as /*VisualElement*/ BaseHandle;
                if (ve == null)
                {
                    continue;
                }
                Apply(ve, inheriting: true);
            }
        }