Bonjour,

je cherche à faire une validation de formulaire,
j'ai ma classe décrivant l'objet source du formulaire :
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
 
public class POItem
    {
        #region Attributs
        private int _id { get; set; }
        private string _text { get; set; }
        private DateTime _date { get; set; }
        private List<AnotherItem> _otherItem { get; set; }
        #endregion
 
        #region Propriétés
        /// <summary>
        /// id
        /// </summary>
        [Required()]
        [Display(Name = "id: *", Description = "id de l'item")]
        public int Id
        {
            get
            {
                return this._id;
            }
            set
            {
                if (value == -1)
                {
                    throw new ValidationException("id obligatoire");
                }
                this._id = value;
            }
 
        }
        /// <summary>
        /// text
        /// </summary>
        [Required()]
        [Display(Name = "Text: *", Description = "Text")]
        public string Text
        {
            get
            {
                return this._text;
            }
            set
            {
                if (string.IsNullOrEmpty(value))
                {
                    value = null;
                    throw new ValidationException("Texte obligatoire");
                }
 
                if ((this._text != value))
                    this._text = value;
            }
 
        }
        /// <summary>
        /// date
        /// </summary>
        [Required()]
        [Display(Name = "Date: *", Description = "Date")]
        public string Date
        {
            get
            {
                return this._date;
            }
            set
            {
                if (string.IsNullOrEmpty(value))
                {
                    value = null;
                    throw new ValidationException("Date obligatoire");
                }
 
                if ((this._date != value))
                    this._date = value;
            }
 
        }
        /// <summary>
        /// Other
        /// </summary>
        [Required()]
        [Display(Name = "Autre : *", Description = "Autre")]
        public List<AnotherItem> OtherItem
        {
            get
            {
                return this._otherItem;
            }
            set
            {
                this._otherItem = value;
            }
 
        }
        #endregion
    }
code behind je fais juste :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
ThePOItem = new POItem();
this.LayoutRoot.DataContext = ThePOItem;
dans le XAML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
<ComboBox SelectedValue="{Binding Id, Mode=TwoWay, ValidatesOnExceptions=true}" ></ComboBox>
<TextBox Text="{Binding Text, Mode=TwoWay, ValidatesOnExceptions=true}"  ></TextBox>
<toolkit:DatePicker     SelectedDate="{Binding Date,Mode=TwoWay}" />
<ListBox  SelectedItem="{Binding OtherItem, Mode=TwoWay, ValidatesOnExceptions=true}" SelectionMode="Multiple"></ListBox>
pour la combobox, textbox, datepicker et listbox SelectionMode Single pas de problème çela fonctionne bien,
pour la listbox SelectionMode Multiple cela ne fonctionne pas. (SelectedItems n'éxiste pas dans le XAML)

y a t il une solution à par : http://stackoverflow.com/questions/1...n-in-viewmodel.
je trouve ça très lourd à implémenter.

Merci d'avance
ALCINA