Esempio n. 1
0
        /// <summary>
        /// Applies any delayed bindings to a control.
        /// </summary>
        /// <param name="control">The control.</param>
        public static void ApplyBindings(IControl control)
        {
            List <Entry> bindings;

            if (_entries.TryGetValue(control, out bindings))
            {
                foreach (var binding in bindings)
                {
                    control.Bind(binding.Property, binding.Binding);
                }

                _entries.Remove(control);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Applies any delayed bindings to a control.
        /// </summary>
        /// <param name="control">The control.</param>
        public static void ApplyBindings(IControl control)
        {
            List<Entry> bindings;

            if (_entries.TryGetValue(control, out bindings))
            {
                foreach (var binding in bindings)
                {
                    control.Bind(binding.Property, binding.Binding);
                }

                _entries.Remove(control);
            }
        }
        private static IDisposable BindDataContextToTag(IControl source, IControl target)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            var data = source.GetObservable(Control.DataContextProperty);

            if (data != null)
            {
                return(target.Bind(Control.TagProperty, data));
            }
            return(null);
        }
Esempio n. 4
0
        /// <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(IControl target, AvaloniaProperty property, IBinding binding)
        {
            if (target.IsInitialized)
            {
                target.Bind(property, binding);
            }
            else
            {
                List <Entry> bindings;

                if (!_entries.TryGetValue(target, out bindings))
                {
                    bindings = new List <Entry>();
                    _entries.Add(target, bindings);

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

                bindings.Add(new Entry(binding, property));
            }
        }
Esempio n. 5
0
        /// <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(IControl target, AvaloniaProperty property, IBinding binding)
        {
            if (target.IsInitialized)
            {
                target.Bind(property, binding);
            }
            else
            {
                List<Entry> bindings;

                if (!_entries.TryGetValue(target, out bindings))
                {
                    bindings = new List<Entry>();
                    _entries.Add(target, bindings);

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

                bindings.Add(new Entry(binding, property));
            }
        }
Esempio n. 6
0
 public override void Apply(IControl control)
 {
     control.Bind(Property, Binding);
 }