12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Linq;
- using System.Threading.Tasks;
- using comal.timesheets.Tasks;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace comal.timesheets
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class EquipmentList
- {
- public EquipmentList()
- {
- InitializeComponent();
-
- Equipment.Columns
- .BeginUpdate()
- .Clear()
- .Add(new MobileGridTextColumn<EquipmentShell>() { Column = x => x.Code, Width = 100 })
- .Add(new MobileGridTextColumn<EquipmentShell>() { Column = x => x.Description, Width = GridLength.Star })
- .EndUpdate();
- RefreshData(false);
-
- }
-
- private void RefreshData(bool force)
- {
- App.Data.Equipment.Refresh(force,
- () => Device.BeginInvokeOnMainThread(() =>
- {
- Equipment.ItemsSource = App.Data.Equipment.Items;
- })
- );
- }
-
- private void Equipment_OnRefreshRequested(object sender, MobileGridRefreshRequestArgs args)
- {
- RefreshData(true);
- }
-
- private void Equipment_OnSelectionChanged(object sender, MobileGridSelectionArgs args)
- {
- var shell = args.Selection.FirstOrDefault() as EquipmentShell;
- if (shell != null)
- {
- EquipmentDetailsPage page = new EquipmentDetailsPage(shell.ID);
- Navigation.PushAsync(page);
- }
- }
- }
- }
|