1 pièce(s) jointe(s)
WPF : DependencyProperty dans un MVVM Model
Bonjour, dans une solution WPF j'utilise le principe de MVVM. Et je souhaite dans mon Model ajouter une DependencyProperty comme suit :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| using System.ComponentModel;
using System.Windows;
namespace ControlsLibrary.Model
{
public class CtrTextBoxModel : INotifyPropertyChanged
{
private string _text;
public string Text
{
get => _text;
set
{
_text = value;
OnPropertyChanged(nameof(Text));
}
}
public CtrTextBoxModel()
{
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public int MyProperty
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(int), typeof(CtrTextBoxModel), new PropertyMetadata(0));
}
} |
Malheureusement les propriétes GetValues et SetValues ne sont pas reconnues comme vous pouvez le voir sur cette capture :
Pièce jointe 646143
Comment pourrais-je faire ??