示例#1
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Items.Clear();
                await hass.Initialize();

                var items = new ObservableCollection <IComponent>();
                foreach (IComponent c in hass.AllEntities)
                {
                    items.Add(c);
                }
                ShellContext.BeginInvokeOnMainThread(() =>
                {
                    Items = items;
                    OnPropertyChanged(nameof(Items));
                    SelectedComponent = items.FirstOrDefault();
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }