How to bind a datatable to a wpf editable combobox: selectedItem showing System.Data.DataRowView

Posted by black sensei on Stack Overflow See other posts from Stack Overflow or by black sensei
Published on 2010-05-19T12:01:41Z Indexed on 2010/05/19 12:50 UTC
Read the original article Hit count: 1002

Filed under:

Hello Good People!!
I bound a datatable to a combobox and defined a dataTemplate in the itemTemplate.i can see desired values in the combobox dropdown list,what i see in the selectedItem is System.Data.DataRowView here are my codes:

 <ComboBox Margin="128,139,123,0" Name="cmbEmail" Height="23" VerticalAlignment="Top" TabIndex="1" ToolTip="enter the email you signed up with here" IsEditable="True" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}">

                      <TextBlock Text="{Binding Path=username}"/>


The code behind is so :

 if (con != null)
    //users table has columns id | username | pass
    SQLiteCommand cmd = new SQLiteCommand("select * from users", con);
    SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
    userdt = new DataTable("users");
    cmbEmail.DataContext = userdt;


I've been looking for something like SelectedValueTemplate or SelectedItemTemplate to do the same kind of data templating but i found none.

I'll like to ask if i'm doing something wrong or it's a known issue for combobox binding?
if something is wrong in my code please point me to the right direction.
thanks for reading this

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wpf-controls