So I am trying to implement a custom binding for a UITextField in MvvmCross, pretty much along the lines of Binding \'GO\' key on Software Keyboard - i.e. trying to bind a t
The question you reference - MVVMCross Binding decimal to UITextField removes decimal point - gives the key to the difference between MvxTargetBinding
and MvxPropertyInfoTargetBinding
:
a non-propertyInfo-based binding
In your case, since you aren't actually using the Text
property via Reflection, then I'd be tempted not to use a PropertyInfoTargetBinding and to steer clear of the Text
name as well - instead just write a custom TargetBinding.
the former is used when replacing an existing binding
This is definitely not true - instead any binding can be used to replace another binding - as the answer on the other question says
MvvmCross operates a simple 'last registered wins' system
For more on custom bindings, take a look at:
Your current binding code is asking for an ICommand:
public override Type TargetType
{
get { return typeof(ICommand); }
}
But your View code is currently binding the View to a string
:
// View
set.Bind(usernameTextField).To(vm => vm.Username);
// ViewModel
private string _username;
public string Username
{
get { return _username; }
set { _username = value; RaisePropertyChanged(() => Username); }
}
To solve this...
string
?