public partial class MainPage : ContentPage
{
SfDataGrid dataGrid;
ViewModel viewModel;
public MainPage()
{
InitializeComponent();
dataGrid = new SfDataGrid();
viewModel = new ViewModel();
this.BindingContext = viewModel;
dataGrid.ColumnSizer = ColumnSizer.Star;
dataGrid.ItemsSource = viewModel.OrdersInfo;
dataGrid.ShowRowHeader = true;
dataGrid.AutoGeneratingColumn += DataGrid_AutoGeneratingColumn;
dataGrid.RowHeaderTemplate = new DataTemplate(() =>
{
var label = new Label();
label.SetBinding(Label.TextProperty, new Binding("Index", BindingMode.Default, null, null, null, null));
return label;
});
this.Content = dataGrid;
}
private void DataGrid_AutoGeneratingColumn(object sender, AutoGeneratingColumnEventArgs e)
{
if (e.Column.MappingName == "Index")
e.Cancel = true;
}
}
|