MainWindow.xaml
|
<Window xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:local="clr-namespace:MonNamespace"
DataContext="{dxmvvm:ViewModelSource Type=local:MainWindowVM}">
|
MainWindowVM.cs
|
using DevExpress.Xpf.Mvvm.POCO;
namespace MonNamespace
{
public class MainWindowVM
{
protected MainWindowVM() { }
public static MainWindowVM Create()
{
return ViewModelSource.Create(() => new MainWindowVM());
}
}
}
|
Des propriétés bindables sont générées pour toutes les propriétés :
- auto-implémentés { get; set; } avec get public et set public ou protected
- virtuelles
MainWindowVM.cs
|
public virtual string BindableProperty { get; set; }
[BindableProperty(isBindable: false)]
public virtual string NonBindableProperty { get; set; }
protected void OnBindablePropertyChanged(string oldValue) { }
protected void OnBindablePropertyChanging(string newValue) { }
[BindableProperty(OnPropertyChangedMethodName = "Update")]
public virtual string BindableProperty { get; set; }
protected void Update() { }
|
Des commandes sont générés pour toutes les méthodes:
- sans paramètre
- avec un paramètre
MainWindow.xaml
|
<Button Content="bBb"
Command="{Binding Path=DoItCommand}" />
|
MainWindowVM.cs
|
public void DoIt(string paramater) { ... }
public bool CanDoIt(string paramater) { returm true; }
[Command(isCommand: false)]
public void NotACommand() { }
|
Erreurs
Ajouter une référence à DevExpress.Xpf.Core.v15.1