예제 #1
0
        public ParentViewModel()
        {
            BusyStack           = new BusyStack();
            BusyStack.OnChanged = (hasItems) =>
            {
                IsBusy = hasItems;
            };

            DemoItems = new DemoItems();
            LogItems  = new LogItems();

            AddLinkedCommand = new AsyncRelayCommand(AddLinked, CanAddLink);
            AddRangeCommand  = new AsyncRelayCommand(AddRange, CanAddRange);
        }
예제 #2
0
        public async Task AddRange()
        {
            using (BusyStack.GetToken())
            {
                var result = await Task.Run(() =>
                {
                    var items = new List <string>();
                    for (var i = 0; i < 5; i++)
                    {
                        items.Add(Guid.NewGuid().ToString());
                    }

                    return(items);
                });

                LogItems.AddRange(result.Select(p => new LogItem(p)));
                DemoItems.AddRange(result.Select(p => new DemoItem(p)));
            }
        }