Ejemplo n.º 1
0
 private async Task ReloadAsync()
 {
     items.Clear();
     context.Dispose();
     context = new DokkaszEntities();
     await LoadAsync();
 }
Ejemplo n.º 2
0
        public TorzsViewModel(Func <DokkaszEntities, IQueryable> query, Func <object, TViewModel> wrap)
        {
            this.query      = query;
            this.wrap       = wrap;
            this.properties = new ObservableCollection <PropertyAdapter <TViewModel> >();
            propertiesView  = new ListCollectionView(this.properties);

            var properties = typeof(TViewModel).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            foreach (var property in properties)
            {
                this.properties.Add(new PropertyAdapter <TViewModel>(property));
            }

            items = new ObservableCollection <TViewModel>();
            items.CollectionChanged += ItemsChanged;
            itemsView = new ListCollectionView(items);
            (ItemsView as INotifyPropertyChanged).PropertyChanged += ItemsView_PropertyChanged;
            context       = new DokkaszEntities();
            loadCommand   = DelegateCommand.FromAsyncHandler(LoadAsync);
            commitCommand = new DelegateCommand(CommitEdit, () => IsEditingItem && !IsLoading);
            cancelCommand = new DelegateCommand(CancelEdit, () => IsEditingItem && !IsLoading);
            reloadCommand = DelegateCommand.FromAsyncHandler(ReloadAsync, () => !IsEditingItem && !IsLoading);
            //editCommand = new DelegateCommand(() => IsEditing = true, () => !IsEditing && !IsLoading);
            toggleEditCommand = new DelegateCommand(ToggleEdit, () => !IsEditingItem && !IsLoading);
            //saveCommand = new DelegateCommand<object>(Save);
            findCommand = new DelegateCommand <object>(Find);
        }