Assembly missing by using ValueMember, DisplayMember and DataSource

853 Views Asked by At

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.

1

There are 1 best solutions below

0
mm8 On BEST ANSWER

The properties are named differently in WPF. Try this:

Accueil.ItemsSource = dt.DefaultView;
Accueil.DisplayMemberPath = "Personnel_Accueil";
Accueil.SelectedValuePath = "Personnel_Accueil";