Пример #1
0
        public void When_ExplicitSetBindingBetweenProperties_IsNotFallBackValue()
        {
            var source = new MyBindingSource {
                IntValue = 42
            };
            var target  = new MyControl();
            var target2 = new MyObjectTest();

            target.SetBinding(MyControl.MyPropertyProperty, new Binding {
                Source = source, Path = nameof(MyBindingSource.IntValue), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });
            target2.Binding(nameof(MyControl.MyProperty), nameof(MyControl.MyProperty), source: target, BindingMode.TwoWay);

            Assert.AreEqual(42, source.IntValue);
            Assert.AreEqual(42, target.MyProperty);
            Assert.AreEqual(42, target2.MyProperty);
        }
Пример #2
0
        public void When_ExplicitUpdateSourceTrigger()
        {
            var source = new MyBindingSource {
                IntValue = 42
            };
            var target = new MyControl();

            target.SetBinding(MyControl.MyPropertyProperty, new Binding {
                Source = source, Path = nameof(MyBindingSource.IntValue), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            });

            Assert.AreEqual(42, source.IntValue);
            Assert.AreEqual(42, target.MyProperty);

            target.MyProperty = -42;

            Assert.AreEqual(42, source.IntValue);
            Assert.AreEqual(-42, target.MyProperty);
        }