本文整理汇总了C#中CheckBox.RequestFocus方法的典型用法代码示例。如果您正苦于以下问题:C# CheckBox.RequestFocus方法的具体用法?C# CheckBox.RequestFocus怎么用?C# CheckBox.RequestFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CheckBox
的用法示例。
在下文中一共展示了CheckBox.RequestFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Binding_TwoWayFromViewModelToCheckBoxWithObserveEvent_BindingGetsUpdated
public void Binding_TwoWayFromViewModelToCheckBoxWithObserveEvent_BindingGetsUpdated()
{
var vm = new TestViewModel
{
Model = new TestModel()
};
var control1 = new CheckBox(Application.Context);
var binding = new Binding<string, bool>(
vm,
() => vm.Model.MyProperty,
control1,
() => control1.Checked,
BindingMode.TwoWay)
.ObserveTargetEvent(); // LostFocus doesn't work programatically with CheckBoxes
Assert.AreEqual(null, vm.Model.MyProperty);
Assert.IsFalse(control1.Checked);
vm.Model.MyProperty = "True";
Assert.AreEqual("True", vm.Model.MyProperty);
Assert.IsTrue(control1.Checked);
control1.RequestFocus();
control1.Checked = false;
Assert.IsFalse(control1.Checked);
Assert.AreEqual("False", vm.Model.MyProperty);
}
示例2: Binding_TwoWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated
public void Binding_TwoWayFromCheckBoxToCheckBoxWithObserveEvent_BindingGetsUpdated()
{
var control1 = new CheckBox(Application.Context);
var control2 = new CheckBox(Application.Context);
var binding = new Binding<bool, bool>(
control1,
() => control1.Checked,
control2,
() => control2.Checked,
BindingMode.TwoWay)
.ObserveSourceEvent() // LostFocus doesn't work programatically with CheckBoxes
.ObserveTargetEvent(); // 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);
control2.RequestFocus();
control2.Checked = false;
Assert.IsFalse(control2.Checked);
Assert.IsFalse(control1.Checked);
}