зеркало из https://github.com/microsoft/MTC_AMP.git
updated readme
This commit is contained in:
Родитель
5d2a5ede0b
Коммит
bfdc1c7ce6
|
@ -1,4 +1,34 @@
|
|||
# AMP - Another Mvvm Project
|
||||
A collection of helper utilities, classes and controls to augment UWP MVVM applications. Built around the popular MVVMLight Framework, AMP was born from several past MTV projects and Alley demos. It helps solve common problems like asynchronous view models, visual state management, and commanding with various controls.
|
||||
Collected from various articles, projects, etc.
|
||||
|
||||
## NavAware ViewModels
|
||||
You may need ViewModels to perform actions when users navigate to the viewmodels respective views. The *NavAwarePage* and *NavAwareViewModel* can be used to accomplish this.
|
||||
|
||||
The *NavAwarePage* base class should be used in place of all XAML *Page* base classes. The *NavAwarePage* will call the *Activate* method on a *NavAwareViewModel* when navigating to a page, and will call the *Decactivate* method when navigating away from a *NavAwarePage*.
|
||||
|
||||
**To use:**
|
||||
Implement your own ViewModel inheriting from the NavAwareViewModel base class:
|
||||
```csharp
|
||||
public class MyViewModel : NavAwareViewModel
|
||||
```
|
||||
Override the *Activate* and/or *Deactivate* methods in your new class:
|
||||
```csharp
|
||||
public override void Activate(object parameter)
|
||||
{ \\ Do work here}
|
||||
|
||||
public override void Deactivate(object parameter)
|
||||
{ \\ Do work here}
|
||||
```
|
||||
|
||||
The passed in *parameter* value will be the same as whatever state object passed in the Page navigation.
|
||||
|
||||
Replace your View's *Page* base class with the *NavAwarePage* class. Your *NavAwareViewModel* must be the *NavAwarePage*'s DataContext in order for the *Activate/Deactive* methods to be called correctly.
|
||||
|
||||
## Asychronous ViewModels
|
||||
Often times, you need to perform actions asynchronously when your viewmodels are loaded.The *AsyncViewModel* is a specific implementation of a *NavAwareViewModel* that allows async operations to be peformed when the ViewModel is initially loaded.
|
||||
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
@ -10,12 +10,7 @@
|
|||
//*********************************************************
|
||||
using AMP.ViewModels;
|
||||
using AMP.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче