1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace comal.timesheets
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class SelectionPage
- {
- private SelectionPageMode _mode;
- private Action<MobileGridColumns> _configure;
- private Func<bool,object> _refresh;
- private Action<object[]> _selected;
-
- public SelectionPage(
- String title,
- SelectionPageMode mode,
- Action<MobileGridColumns> configure,
- Func<bool,object> refresh,
- Action<object[]> selected)
- {
- _mode = mode;
- _configure = configure;
- _refresh = refresh;
- _selected = selected;
-
- InitializeComponent();
-
-
- Title = title;
- _selection.Mode = mode;
-
- if (_mode != SelectionPageMode.Immediate)
- {
- ToolbarItems.Clear();
- ToolbarItems.Add(new ToolbarItem("Select", null, DoSelectItems));
- }
-
-
- }
- protected override void OnAppearing()
- {
- _selection.Load();
- base.OnAppearing();
- }
- private void DoSelectItems()
- {
- _selected?.Invoke(_selection.SelectedItems);
- Navigation.PopAsync();
- }
- private void _selection_OnConfigureColumns(object sender, SelectionViewConfigureArgs args)
- {
- _configure?.Invoke(args.Columns);
- }
- private object _selection_OnRefresh(object sender, SelectionViewRefreshArgs args)
- {
- return _refresh?.Invoke(false);
- }
- private void _selection_OnSelectionChanged(object sender, SelectionViewSelectionChangedArgs args)
- {
- if (_mode == SelectionPageMode.Immediate)
- DoSelectItems();
- }
- }
- }
|