本文整理汇总了C#中DataBinding.UpdateViewModel方法的典型用法代码示例。如果您正苦于以下问题:C# DataBinding.UpdateViewModel方法的具体用法?C# DataBinding.UpdateViewModel怎么用?C# DataBinding.UpdateViewModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBinding
的用法示例。
在下文中一共展示了DataBinding.UpdateViewModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTwoWayHandler
private void AddTwoWayHandler(DataBinding binding)
{
if (binding.ViewProperty == null || binding.ViewProperty.ContainingObject == null) return;
var view = binding.ViewProperty.ContainingObject;
string viewTypeName = view.GetType().FullName;
switch (viewTypeName)
{
// TODO: Add cases here for specialized view types, as needed
case "MonoTouch.UIKit.UITextField":
if (textFieldTextDidChangeObserver == null) {
textFieldTextDidChangeObserver = NSNotificationCenter.DefaultCenter.AddObserver(
UITextField.TextFieldTextDidChangeNotification, HandleTextFieldTextDidChangeNotification
);
}
break;
case "MonoTouch.UIKit.UITextView" : ((UITextView)view).Changed += HandleTextViewChanged;
break;
#if __DIALOG__
case "MonoTouch.Dialog.EntryElement": {
var element = (EntryElement)view;
element.Changed += (s, e) => binding.UpdateViewModel(viewModel, element.Value);
}
break;
case "MonoTouch.Dialog.BooleanElement":
case "MonoTouch.Dialog.BooleanImageElement":
{
var element = (BoolElement)view;
element.ValueChanged += (s, e) => binding.UpdateViewModel(viewModel, element.Value);
}
break;
case "MonoTouch.Dialog.CheckboxElement":
{
var element = (CheckboxElement)view;
element.Tapped += () => binding.UpdateViewModel(viewModel, element.Value);
}
break;
case "MonoTouch.Dialog.DateTimeElement":
case "MonoTouch.Dialog.DateElement":
case "MonoTouch.Dialog.TimeElement":
{
var element = (DateTimeElement)view;
element.DateSelected += (d) => binding.UpdateViewModel(viewModel, d.DateValue);
}
break;
case "MonoTouch.Dialog.RootElement":
{
var rootElement = (RootElement)view;
foreach (var section in rootElement)
{
foreach (var element in section.Elements)
{
var radioElement = element as RadioElement;
if (radioElement != null)
{
radioElement.Tapped += () =>
{
if (binding.ViewModelListPropertyInfo != null)
{
var list = binding.ViewModelListPropertyInfo.GetValue(viewModel) as IList;
int i = rootElement.RadioSelected;
if (list != null && i >= 0 && i < list.Count) binding.UpdateViewModel(viewModel, list[i]);
}
};
}
}
}
}
break;
#endif
default:
if (view is UITableView) break;
throw new NotImplementedException("View type not implemented: " + viewTypeName);
}
}