Trying to follow a tutorial here to create a SfDataGrid, but it is not working. I'm full of doubts on how to implement. My Model Class
namespace Autorizador.Model
{
public class LiberacaoGrid
{
private double dataLib;
private string cliente;
private string vendedor;
private string filial;
public double DataLib
{
get { return dataLib; }
set { this.dataLib = value; }
}
public string Cliente
{
get { return cliente; }
set { this.cliente = value; }
}
public string Vendedor
{
get { return vendedor; }
set { this.vendedor = value; }
}
public string Filial
{
get { return filial; }
set { this.filial = value; }
}
public LiberacaoGrid(double datalib, string cliente, string vendedor, string filial)
{
this.DataLib = datalib;
this.Cliente = cliente;
this.Vendedor = vendedor;
this.Filial = filial;
}
}
Another class called a repository
namespace Autorizador.Model
{
public class LiberacaoRepository
{
DataService dataService;
List<Liberacao> lib;
private ObservableCollection<LiberacaoGrid> orderInfo;
public ObservableCollection<LiberacaoGrid> OrderInfoCollection
{
get { return orderInfo; }
set { this.orderInfo = value; }
}
public LiberacaoRepository()
{
dataService = new DataService();
orderInfo = new ObservableCollection<LiberacaoGrid>();
this.AtualizaDados();
}
public async void AtualizaDados()
{
lib = await dataService.GetLiberaAsync();
}
}
My App.xaml.cs
namespace Autorizador
{
public partial class App : Application
{
SfDataGrid dataGrid;
public App()
{
InitializeComponent();
dataGrid = new SfDataGrid();
MainPage = new ContentPage { Content = dataGrid };
//MainPage = new Autorizador.MainPage();
//MainPage = new NavigationPage(new Autorizador.MainPage());
}
protected override void OnStart()
{
//CrossPushNotification.Current.Unregister();
//CrossPushNotification.Current.Register();
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
MainPage
DataService dataService;
List<Liberacao> lib;
double _idorcamento = 0d;
LiberacaoRepository lRepository = new LiberacaoRepository();
public MainPage()
{
InitializeComponent();
try
{
dataService = new DataService();
AtualizaDados();
//Content = new ScrollView { Content = listaLibera, Orientation = ScrollOrientation.Both };
}
catch(Exception ex)
{
string erro = ex.Message;
}
}
private async void AtualizaDados()
{
try
{
lib = await dataService.GetLiberaAsync();
//listaLibera.ItemsSource = lib.OrderBy(item => item.Cliente).ToList();
dataGrid.ItemsSource = lib.OrderBy(item => item.Cliente).ToList(); //lRepository.OrderInfoCollection;
}
catch (Exception ex)
{
string erro = ex.Message;
}
}
I know I'm missing something in this code, but I do not know what it is