ContactSelectionPage.cs 1.0 KB

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Linq;
  3. using Xamarin.Forms;
  4. namespace comal.timesheets
  5. {
  6. public class ContactSelectionPage : SelectionPage
  7. {
  8. public ContactSelectionPage(Action<ContactShell> action)
  9. : base(
  10. (string)"Select Contact",
  11. (SelectionPageMode)SelectionPageMode.Immediate,
  12. (columns) =>
  13. {
  14. columns
  15. .BeginUpdate()
  16. .Clear()
  17. .Add(new MobileGridTextColumn<ContactShell>() { Column = x => x.Name, Width = GridLength.Star })
  18. .Add(new MobileGridTextColumn<ContactShell>() { Column = x => x.Street, Width = GridLength.Auto })
  19. .Add(new MobileGridTextColumn<ContactShell>() { Column = x => x.City, Width = GridLength.Auto })
  20. .EndUpdate();
  21. },
  22. (force) => App.Data.Contacts.Refresh(force),
  23. (items) => action?.Invoke(items.FirstOrDefault() as ContactShell)
  24. ) { }
  25. }
  26. }