I have a DataGrid
bind to a database with one Table and one Column (FooTable and FooName).
With my following code, I can bind DataGrid
to Dat
pls post your xaml or cs code where you bind the Itemssource.
does your DataSet_Add_Click add the row to your datatable? if yes then it seems is just a refresh/binding problem with your datagrid.
when i work with datatables and datagrid i always use the following
//ctor or init
dt = ds.Tables["FooTable"];
//the next line you have to write after you initialize your datatable
this.MyView = (BindingListCollectionView)CollectionViewSource.GetDefaultView(this.dt);
XAML
Refresh
this.MyView.Refresh();
EDIT: MyView is a property
public BindingListCollectionView MyView
{
get {return this._myview;}
set {this._myview = value; OnPropertyChanged("MyView");
}
you can do binding in code.
Binding myBinding = new Binding("MyView");
myBinding.Source = this;//the instance with the MyView property
mydatagridctrl.SetBinding(ItemsControl.ItemsSourceProperty, myBinding);