MvvmCross Bind to UIButton.TitleLabel.Text
The easiest way to bind a UIButton Title:
set.Bind(btnFoo).For("Title").To(vm => vm.BtnFooText);
For debugging issues, enabling trace may help - see MvvmCross Mvx.Trace usage
For binding a property on a fixed pre-existing subcontrol of a subcontrol then this approach should work:
set.Bind(sub.subSub).For(c => c.PropertyName).To(vm => vm.Foo);
However, that won't continue to work if the sub control then changes its sub control at any point. For those cases, look at custom bindings - eg see http://slodge.blogspot.co.uk/2013/06/n28-custom-bindings-n1-days-of-mvvmcross.html
For the specific case of a uibutton, you can just bind its "Title" - see Fluent Bindings and UIButton titles
For me UIButton binding to TitleLabel doesn't work. I came up with custom binding which works great and way flexible:
Apply binding:
set.Bind(FinishedButton).For(UIButtonTextBinding.Property).To(v => v.FinishActionText);
Binding code:
public class UIButtonTextBinding : MvxTargetBinding
{
public const string Property = "ButtonText";
protected UIButton View
{
get { return Target as UIButton; }
}
public UIButtonTextBinding(UIButton target)
: base(target)
{
}
public override void SetValue(object value)
{
var view = View;
if (view == null)
return;
var stringValue = value as string;
view.SetTitle(stringValue, UIControlState.Normal);
}
public override Type TargetType
{
get { return typeof(string); }
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.OneWay; }
}
}