public static IDisposable Bind(IStyledElement target, string className, IBinding source, object anchor)
 {
     if (!s_RegisteredProperties.TryGetValue(className, out var prop))
     {
         s_RegisteredProperties[className] = prop = RegisterClassProxyProperty(className);
     }
     return(target.Bind(prop, source, anchor));
 }
        /// <summary>
        /// Adds a delayed binding to a control.
        /// </summary>
        /// <param name="target">The control.</param>
        /// <param name="property">The property on the control to bind to.</param>
        /// <param name="binding">The binding.</param>
        public static void Add(IStyledElement target, AvaloniaProperty property, IBinding binding)
        {
            if (target.IsInitialized)
            {
                target.Bind(property, binding);
            }
            else
            {
                if (!_entries.TryGetValue(target, out List <Entry> bindings))
                {
                    bindings = new List <Entry>();
                    _entries.Add(target, bindings);

                    // TODO: Make this a weak event listener.
                    target.Initialized += ApplyBindings;
                }

                bindings.Add(new BindingEntry(property, binding));
            }
        }
 public override void Apply(IStyledElement control)
 {
     control.Bind(Property, Binding);
 }