I have a recurring error when using ValueMember
, DisplayMember
and DataSource
.
This is a compilation error :
CS1061 C# 'ComboBox' does not contain a definition for and no accessible extension method accepting a first argument of type 'ComboBox' could be found (are you missing a using directive or an assembly reference?).
Here's the code-behind :
Accueil.DataSource = dt; // <- Doesn't compile
Accueil.DisplayMember = "Personnel_Accueil"; // <- Doesn't compile
Accueil.ValueMember = "Personnel_Accueil"; // <- Doesn't compile
Why do i get this error ?
Thank you in advance,
Zancrew.
The properties are named differently in WPF. Try this:
Accueil.ItemsSource = dt.DefaultView;
Accueil.DisplayMemberPath = "Personnel_Accueil";
Accueil.SelectedValuePath = "Personnel_Accueil";