MyTimesheets.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Xamarin.Forms;
  2. using System.Threading.Tasks;
  3. namespace comal.timesheets
  4. {
  5. public partial class MyTimesheets : BasePage
  6. {
  7. public MyTimesheets()
  8. {
  9. InitializeComponent();
  10. TimeSheets.Columns
  11. .BeginUpdate()
  12. .Clear()
  13. .Add(new MobileGridDateColumn<TimeSheetShell>()
  14. { Column = x => x.Date, Format = "dd MMM yy", Width = GridLength.Auto })
  15. .Add(new MobileGridDateColumn<TimeSheetShell>()
  16. { Column = x => x.Date, Format = "dddd", Width = GridLength.Star })
  17. .Add(new MobileGridTimeColumn<TimeSheetShell>()
  18. { Column = x => x.Start, Width = GridLength.Auto })
  19. .Add(new MobileGridTimeColumn<TimeSheetShell>()
  20. { Column = x => x.Finish, Width = GridLength.Auto })
  21. .Add(new MobileGridImageColumn<TimeSheetShell>() { Column = x => x.Approved, Width = 40 })
  22. .EndUpdate();
  23. }
  24. public void RefreshData(bool force)
  25. {
  26. App.Data.TimeSheets.Refresh(
  27. force,
  28. () => Device.BeginInvokeOnMainThread(
  29. () =>
  30. {
  31. TimeSheets.ItemsSource = App.Data.TimeSheets.Items;
  32. }
  33. )
  34. );
  35. }
  36. protected override void OnAppearing()
  37. {
  38. base.OnAppearing();
  39. RefreshData(false);
  40. }
  41. private void TimeSheets_OnRefreshRequested(object sender, MobileGridRefreshRequestArgs args)
  42. {
  43. RefreshData(true);
  44. }
  45. }
  46. }