/// <summary> /// Applies a binding subject to a property on an instance. /// </summary> /// <param name="target">The target instance.</param> /// <param name="property">The target property.</param> /// <param name="subject">The binding subject.</param> internal void Bind(IObservablePropertyBag target, PerspexProperty property, ISubject <object> subject) { Contract.Requires <ArgumentNullException>(target != null); Contract.Requires <ArgumentNullException>(property != null); Contract.Requires <ArgumentNullException>(subject != null); var mode = Mode == BindingMode.Default ? property.DefaultBindingMode : Mode; switch (mode) { case BindingMode.Default: case BindingMode.OneWay: target.Bind(property, subject, Priority); break; case BindingMode.TwoWay: target.BindTwoWay(property, subject, Priority); break; case BindingMode.OneTime: target.GetObservable(Control.DataContextProperty).Subscribe(dataContext => { subject.Take(1).Subscribe(x => target.SetValue(property, x, Priority)); }); break; case BindingMode.OneWayToSource: target.GetObservable(property).Subscribe(subject); break; } }
internal void Bind(IObservablePropertyBag target, PerspexProperty property, ISubject<object> subject) { var mode = BindingMode == BindingMode.Default ? property.DefaultBindingMode : BindingMode; switch (mode) { case BindingMode.Default: case BindingMode.OneWay: target.Bind(property, subject); break; case BindingMode.TwoWay: target.BindTwoWay(property, subject); break; case BindingMode.OneTime: target.GetObservable(Control.DataContextProperty).Subscribe(dataContext => { subject.Take(1).Subscribe(x => target.SetValue(property, x)); }); break; case BindingMode.OneWayToSource: target.GetObservable(property).Subscribe(subject); break; } }
internal void Bind(IObservablePropertyBag target, PerspexProperty property, ISubject <object> subject) { var mode = BindingMode == BindingMode.Default ? property.DefaultBindingMode : BindingMode; switch (mode) { case BindingMode.Default: case BindingMode.OneWay: target.Bind(property, subject); break; case BindingMode.TwoWay: target.BindTwoWay(property, subject); break; case BindingMode.OneTime: target.GetObservable(Control.DataContextProperty).Subscribe(dataContext => { subject.Take(1).Subscribe(x => target.SetValue(property, x)); }); break; case BindingMode.OneWayToSource: target.GetObservable(property).Subscribe(subject); break; } }
/// <summary> /// Applies a binding subject to a property on an instance. /// </summary> /// <param name="target">The target instance.</param> /// <param name="property">The target property.</param> /// <param name="subject">The binding subject.</param> internal void Bind(IObservablePropertyBag target, PerspexProperty property, ISubject<object> subject) { Contract.Requires<ArgumentNullException>(target != null); Contract.Requires<ArgumentNullException>(property != null); Contract.Requires<ArgumentNullException>(subject != null); var mode = Mode == BindingMode.Default ? property.DefaultBindingMode : Mode; switch (mode) { case BindingMode.Default: case BindingMode.OneWay: target.Bind(property, subject, Priority); break; case BindingMode.TwoWay: target.BindTwoWay(property, subject, Priority); break; case BindingMode.OneTime: target.GetObservable(Control.DataContextProperty).Subscribe(dataContext => { subject.Take(1).Subscribe(x => target.SetValue(property, x, Priority)); }); break; case BindingMode.OneWayToSource: target.GetObservable(property).Subscribe(subject); break; } }