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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
namespace WpfCombo
{
public class Personne : INotifyPropertyChanged
{
public Personne()
{
Nom = string.Empty;
Prenom = string.Empty;
Genre = string.Empty;
}
public Personne(string n, string pn,string gr)
: this()
{
Nom = n;
Prenom = pn;
Genre = gr;
}
private string _nom;
public string Nom
{
get { return _nom; }
set
{
_nom = value;
OnNotifyPropertyChanged("Nom");
}
}
private string _prenom;
public string Prenom
{
get { return _prenom; }
set
{
_prenom = value;
OnNotifyPropertyChanged("Prenom");
}
}
private string _genre;
public string Genre
{
get { return _genre; }
set
{
_genre = value;
OnNotifyPropertyChanged("Genre");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnNotifyPropertyChanged(string propName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propName));
}
}
}
public class Persons : ObservableCollection<Personne>
{
private Personne p;
public Persons()
{
for (int i = 1; i < 21; i++)
{
string g = string.Empty;
if (i % 2 == 0)
{
g = "Masculin";
}
else
{
g = "Feminin";
}
p = new Personne("Nom"+i.ToString() ,"Prenom"+i.ToString(),
g);
this.Add(p);
}
}
}
} |
Partager