Adding new rows to DataView and binding to ComboBox

less than 1 minute read

Even though it’s a very, very simple problem, it took me a while since I was focusing on a different part of the problem. Here is the code snippet in case anybody needs. Binding to ComboBox is a bonus 🙂

void addNewRow(DataView dataView)
{
    DataRowView newRow = dataView.AddNew();
    newRow["Column Name"] = "Column Value";
    newRow.EndEdit();

    comboBoxViews.ItemsSource = dataView.Cast<DataRowView>().Select(o => o["Column Name"]);
}

Categories:

Updated:

Leave a Comment