Multiple data binding objects on a page
валера карманов
396
Reputation points
There is a code that goes to another page with the data binding specified
await Navigation.PushAsync(new HelpQuestionPage {
BindingContext = e.CurrentSelection.FirstOrDefault()
});
In the class constructor I get the title to use as the page title
public HelpQuestionPage()
{
SetBinding(TitleProperty, new Binding { Path = "title" });
}
This is all good, works like clockwork. HOWEVER. There is a function for the class "DataTemplate"
private Layout _GetDataTemplate()
{
var field = new HelpQuestionRendererField();
field.SetBindingLabel(Label.TextProperty, new Binding {
Source = BindingContext, Path = "title"
});
var stackLayout = new VerticalStackLayout();
field.RenderField(stackLayout);
return stackLayout;
}
It uses the "BindingContext" data binding object, which is bound to the page itself, but I need the data binding that belongs to the "DataTemplate" class. How do I get it?
Sign in to answer