本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}