Bonjour,
je suis en train de tester les dataannotations avec SL4 voici ce que j'ai fais.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 <Grid x:Name="LayoutRoot" Background="White">
        <TextBox Name="textBox1" VerticalAlignment="Top" Width="120" Text="{Binding Nom,NotifyOnValidationError=True,ValidatesOnExceptions=True}" />
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="151,41,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    </Grid>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            voiture v=new voiture();
            this.DataContext = v;
        }
 
 
    }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
  public class voiture : INotifyPropertyChanged
 
    {
        private string _Nom;
        [Required(ErrorMessage="veuillez entrer un nom")]
        [StringLength(32, MinimumLength = 2,ErrorMessage="Veuillez plus de 2 lettres")]
        public string Nom
        {
            get { return this._Nom; }
            set
            {
                if (value != this._Nom)
                {
                    this._Nom = value;
                    NotifyPropertyChanged("Nom");
                }
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
 
    }
Mon souci est le fait que le textbox ne se met jamais en erreur.

Savez vous d'où vient le souci ?

Merci