I have a problem binding data in a custom view in Xamarin forms to the view model of the containing page.
My Custom View is very simple, a pair of labels representin
I was able to get this to work by doing
public KeyValueView()
{
InitializeComponent();
this.VerticalOptions = LayoutOptions.Start;
this.Content.BindingContext = this;
}
and then doing this in the xaml.cs for the view you're using the custom view in:
public ParentView()
{
InitializeComponent();
BindingContext = this;
}
For an Entry field, which gave me problems, I had to make sure the defaultBindingMode parameter was set to TwoWay.