当前位置: 首页>>代码示例>>C#>>正文


C# Helpers.Binding类代码示例

本文整理汇总了C#中Helpers.Binding的典型用法代码示例。如果您正苦于以下问题:C# Helpers.Binding类的具体用法?C# Helpers.Binding怎么用?C# Helpers.Binding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Helpers.Binding类属于命名空间,在下文中一共展示了Helpers.Binding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated

        public void Binding_TwoWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new EditText(Application.Context);
            var control2 = new EditText(Application.Context);

            _binding = new Binding<string, string>(
                control1,
                () => control1.Text,
                control2,
                () => control2.Text,
                BindingMode.TwoWay)
                .UpdateSourceTrigger<View.LongClickEventArgs>("LongClick")
                .ObserveTargetEvent<View.LongClickEventArgs>("LongClick");

            Assert.AreEqual(string.Empty, control1.Text);
            Assert.AreEqual(control1.Text, control2.Text);
            var value = DateTime.Now.Ticks.ToString();
            control1.Text = value;
            Assert.AreEqual(value, control1.Text);
            Assert.AreEqual(string.Empty, control2.Text);
            control1.PerformLongClick();
            Assert.AreEqual(control1.Text, control2.Text);

            var newValue = value + "Suffix";
            control2.Text = newValue;
            Assert.AreEqual(newValue, control2.Text);
            Assert.AreEqual(value, control1.Text);
            control2.PerformLongClick();
            Assert.AreEqual(control2.Text, control1.Text);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:30,代码来源:UpdateTriggerNonDefaultEventTest.cs

示例2: SetCommand_OnBarButtonWithBinding_ParameterShouldUpdate

        public void SetCommand_OnBarButtonWithBinding_ParameterShouldUpdate()
        {
            var value = DateTime.Now.Ticks.ToString();

            var vmSource = new TestViewModel
            {
                Model = new TestModel
                {
                    MyProperty = value
                }
            };

            var vmTarget = new TestViewModel();

            var control = new UIBarButtonItemEx();

            _binding = new Binding<string, string>(
                vmSource,
                () => vmSource.Model.MyProperty);

            control.SetCommand(
                "Clicked",
                vmTarget.SetPropertyCommand,
                _binding);

            Assert.IsNull(vmTarget.TargetProperty);
            control.PerformEvent();
            Assert.AreEqual(value, vmTarget.TargetProperty);

            value += "Test";
            vmSource.Model.MyProperty = value;
            control.PerformEvent();
            Assert.AreEqual(value, vmTarget.TargetProperty);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:34,代码来源:SetCommandTest.cs

示例3: BindingSource_NewBindingWithPrivateProperty_NoError

        public void BindingSource_NewBindingWithPrivateProperty_NoError()
        {
            // For comparison only

            var vmSource = new TestViewModel
            {
                Model = new TestModel
                {
                    MyProperty = "Initial value"
                }
            };

            var vmTarget = new TestViewModel();

            _binding = new Binding<string, string>(
                vmSource,
                () => vmSource.Model.MyProperty,
                vmTarget,
                () => vmTarget.TargetProperty);

            Assert.AreEqual(vmSource.Model.MyProperty, vmTarget.TargetProperty);
            var newValue1 = DateTime.Now.Ticks.ToString();
            vmSource.Model.MyProperty = newValue1;
            Assert.AreEqual(vmSource.Model.MyProperty, vmTarget.TargetProperty);

            // Actual test

            VmSourcePrivate = new TestViewModel
            {
                Model = new TestModel
                {
                    MyProperty = "Initial value"
                }
            };

            VmTarget = new TestViewModel();

            _binding = new Binding<string, string>(
                VmSourcePrivate,
                () => VmSourcePrivate.Model.MyProperty,
                VmTarget,
                () => VmTarget.TargetProperty);

            Assert.AreEqual(VmSourcePrivate.Model.MyProperty, VmTarget.TargetProperty);
            var newValue2 = DateTime.Now.Ticks.ToString();
            VmSourcePrivate.Model.MyProperty = newValue2;
            Assert.AreEqual(VmSourcePrivate.Model.MyProperty, VmTarget.TargetProperty);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:48,代码来源:BindingSourceTest.cs

示例4: Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new EditText(Application.Context);
            var control2 = new CheckBox(Application.Context);

            _binding = new Binding<bool, string>(
                control2,
                () => control2.Checked,
                control1,
                () => control1.Text);

            Assert.AreEqual("False", control1.Text);
            Assert.IsFalse(control2.Checked);
            control2.Checked = true;
            Assert.AreEqual("True", control1.Text);
            Assert.IsTrue(control2.Checked);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:17,代码来源:UpdateTriggerImplicitTest.cs

示例5: Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new UITextViewEx();
            var control2 = new UISwitchEx();

            _binding = new Binding<bool, string>(
                control2,
                () => control2.On,
                control1,
                () => control1.Text);

            Assert.AreEqual("False", control1.Text);
            Assert.IsFalse(control2.On);
            control2.On = true;
            Assert.AreEqual("True", control1.Text);
            Assert.IsTrue(control2.On);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:17,代码来源:UpdateTriggerImplicitTest.cs

示例6: Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new UISwitchEx();
            var control2 = new UISwitchEx();

            _binding = new Binding<bool, bool>(
                control1,
                () => control1.On,
                control2,
                () => control2.On);

            Assert.IsFalse(control1.On);
            Assert.IsFalse(control2.On);
            control1.On = true;
            Assert.IsTrue(control1.On);
            Assert.IsTrue(control2.On);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:17,代码来源:UpdateTriggerImplicitTest.cs

示例7: Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new CheckBox(Application.Context);
            var control2 = new CheckBox(Application.Context);

            _binding = new Binding<bool, bool>(
                control1,
                () => control1.Checked,
                control2,
                () => control2.Checked);

            Assert.IsFalse(control1.Checked);
            Assert.IsFalse(control2.Checked);
            control1.Checked = true;
            Assert.IsTrue(control1.Checked);
            Assert.IsTrue(control2.Checked);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:17,代码来源:UpdateTriggerImplicitTest.cs

示例8: Binding_OneWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToEditTextWithObserveEvent_BindingGetsUpdated()
        {
            var control1 = new EditText(Application.Context);
            var control2 = new CheckBox(Application.Context);

            _binding = new Binding<bool, string>(
                control2,
                () => control2.Checked,
                control1,
                () => control1.Text)
                .ObserveSourceEvent<CompoundButton.CheckedChangeEventArgs>("CheckedChange");

            Assert.AreEqual("False", control1.Text);
            Assert.IsFalse(control2.Checked);
            control2.Checked = true;
            Assert.AreEqual("True", control1.Text);
            Assert.IsTrue(control2.Checked);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:18,代码来源:ObserveEventTest.cs

示例9: Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
        {
            var control1 = new CheckBox(Application.Context);
            var control2 = new CheckBox(Application.Context);

            _binding = new Binding<bool, bool>(
                control1,
                () => control1.Checked,
                control2,
                () => control2.Checked)
                .ObserveSourceEvent(UpdateTriggerMode.PropertyChanged);

            Assert.IsFalse(control1.Checked);
            Assert.IsFalse(control2.Checked);
            control1.Checked = true;
            Assert.IsTrue(control1.Checked);
            Assert.IsTrue(control2.Checked);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:18,代码来源:ObserveEventPropertyChangedTest.cs

示例10: Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new EditText(Application.Context);
            var control2 = new CheckBox(Application.Context);

            _binding = new Binding<bool, string>(
                control2,
                () => control2.Checked,
                control1,
                () => control1.Text)
                .UpdateSourceTrigger(); // LostFocus doesn't work programatically with CheckBoxes

            Assert.AreEqual("False", control1.Text);
            Assert.IsFalse(control2.Checked);
            control2.Checked = true;
            Assert.IsTrue(control2.Checked);
            Assert.AreEqual("True", control1.Text);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:18,代码来源:UpdateTriggerLostFocusTest.cs

示例11: Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
        {
            var control1 = new CheckBox(Application.Context);
            var control2 = new CheckBox(Application.Context);

            _binding = new Binding<bool, bool>(
                control1,
                () => control1.Checked,
                control2,
                () => control2.Checked)
                .ObserveSourceEvent(); // LostFocus doesn't work programatically with CheckBoxes

            Assert.IsFalse(control1.Checked);
            Assert.IsFalse(control2.Checked);
            control1.Checked = true;
            Assert.IsTrue(control1.Checked);
            Assert.IsTrue(control2.Checked);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:18,代码来源:ObserveEventLostFocusTest.cs

示例12: Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToCheckBoxWithUpdateTrigger_BindingGetsUpdated()
        {
            var control1 = new CheckBox(Application.Context);
            var control2 = new CheckBox(Application.Context);

            _binding = new Binding<bool, bool>(
                control1,
                () => control1.Checked,
                control2,
                () => control2.Checked)
                .UpdateSourceTrigger<CompoundButton.CheckedChangeEventArgs>("CheckedChange");

            Assert.IsFalse(control1.Checked);
            Assert.IsFalse(control2.Checked);
            control1.Checked = true;
            Assert.IsTrue(control1.Checked);
            Assert.IsTrue(control2.Checked);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:18,代码来源:UpdateTriggerTest.cs

示例13: Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
        {
            var vm = new TestViewModel
            {
                Model = new TestModel()
            };

            var control1 = new UISwitchEx();

            _binding = new Binding<bool, string>(
                control1,
                () => control1.On,
                vm,
                () => vm.Model.MyProperty);

            Assert.AreEqual("False", vm.Model.MyProperty);
            Assert.IsFalse(control1.On);
            control1.On = true;
            Assert.AreEqual("True", vm.Model.MyProperty);
            Assert.IsTrue(control1.On);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:21,代码来源:UpdateTriggerImplicitTest.cs

示例14: Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated

        public void Binding_OneWayFromCheckBoxToViewModelWithUpdateTrigger_BindingGetsUpdated()
        {
            var vm = new TestViewModel
            {
                Model = new TestModel()
            };

            var control1 = new CheckBox(Application.Context);

            _binding = new Binding<bool, string>(
                control1,
                () => control1.Checked,
                vm,
                () => vm.Model.MyProperty);

            Assert.AreEqual("False", vm.Model.MyProperty);
            Assert.IsFalse(control1.Checked);
            control1.Checked = true;
            Assert.AreEqual("True", vm.Model.MyProperty);
            Assert.IsTrue(control1.Checked);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:21,代码来源:UpdateTriggerImplicitTest.cs

示例15: Binding_OneWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated

        public void Binding_OneWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
        {
            var control1 = new EditText(Application.Context);
            var control2 = new EditText(Application.Context);

            _binding = new Binding<string, string>(
                control1,
                () => control1.Text,
                control2,
                () => control2.Text)
                .ObserveSourceEvent<View.LongClickEventArgs>("LongClick");

            Assert.AreEqual(string.Empty, control1.Text);
            Assert.AreEqual(control1.Text, control2.Text);
            var value = DateTime.Now.Ticks.ToString();
            control1.Text = value;
            Assert.AreEqual(value, control1.Text);
            Assert.AreEqual(string.Empty, control2.Text);
            control1.PerformLongClick();
            Assert.AreEqual(control1.Text, control2.Text);
        }
开发者ID:dsfranzi,项目名称:MVVMLight,代码行数:21,代码来源:ObserveEventNonDefaultEventTest.cs


注:本文中的Helpers.Binding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。