Hi, in this documentation https://documentation.devexpress.com/#Xamarin/clsDevExpressMobileDataGridTemplateColumntopic there are example code for binding using devexpress gridcontrol. In the Xaml:MainPage.xaml tab could someone explain this binding:
<Grid BindingContext="{Binding Source}" Padding="0,15,0,15">
and how to do this in code?
I have tried the following:
templateColumn.DisplayTemplate = new DataTemplate (() => {
Label firstNameLabel = new Label();
firstNameLabel.FontAttributes = FontAttributes.Bold;
firstNameLabel.FontSize = 20;
firstNameLabel.SetBinding(Label.TextProperty, new Binding("FirstName"));
Label emailLabel = new Label();
emailLabel.SetBinding(Label.TextProperty, new Binding("Email"));
Grid grid = new Grid {
RowDefinitions = {
new RowDefinition() { Height = GridLength.Auto },
new RowDefinition() { Height = GridLength.Auto }
},
Children = {
firstNameLabel,
emailLabel
}
};
grid.SetBinding(Grid.BindingContextProperty, new Binding("Source"));
return grid;
});
but I keep getting this error:
System.NullReferenceException: Object reference not set to an instance of an object
at at DevExpress.Mobile.DataGrid.Internal.ObjectRowData