123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace comal.timesheets
- {
- public delegate void DataGridHostSaved(List<DataGridViewModelItem> selecteditems);
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class DataGridHost : ContentPage
- {
- public event DataGridHostSaved OnSaved;
- public MobileDataGrid DataGrid { get; set; }
- public DataGridHost(MobileDataGrid datagrid)
- {
- InitializeComponent();
- NavigationPage.SetHasBackButton(this, false);
- DataGrid = datagrid;
- datagrid.OnOptionsSet += Datagrid_OnTitleSet;
- stackLayout.Children.Add(datagrid);
- }
- private void Datagrid_OnTitleSet(string title, DataGridSaveType savetype)
- {
- Device.BeginInvokeOnMainThread(() =>
- {
- titleLbl.Text = title + " List";
- saveBtn.IsVisible = savetype == DataGridSaveType.None ? false : true;
- });
- }
- private void CancelBtn_Clicked(object sender, EventArgs e)
- {
- Navigation.PopAsync();
- }
- private void SaveBtn_Clicked(object sender, EventArgs e)
- {
- OnSaved?.Invoke(CreateSelectedList());
- }
- private List<DataGridViewModelItem> CreateSelectedList()
- {
- var list = DataGrid.Items.Where(x => x.IsSelected == true);
- List<DataGridViewModelItem> newlist = new List<DataGridViewModelItem>();
- foreach (var item in list)
- {
- newlist.Add(item);
- }
- return newlist;
- }
- }
- }
|