コード例 #1
0
        async Task ExecuteLoadGuardsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Guards.Clear();
                var guards = await GuardDataStore.GetMembersAsync(true);

                foreach (var guard in guards)
                {
                    Guards.Add(guard);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #2
0
        public GuardsViewModel()
        {
            Title             = "Browse";
            Guards            = new ObservableCollection <Guard>();
            LoadGuardsCommand = new Command(async() => await ExecuteLoadGuardsCommand());

            MessagingCenter.Subscribe <NewGuardPage, Guard>(this, "AddGuard", async(obj, guard) =>
            {
                var _guard = guard as Guard;
                Guards.Add(_guard);
                await GuardDataStore.AddMemberAsync(_guard);
            });
        }