seb
seb

Reputation: 313

Double binding on a WPF DataGrid?

I am new to mvvm and I am not really familiar with the control DataGrid. I would like to known if we can do multiple binding on a DataGrid or anything.

Let me explain, I have 3 TextBox ( ProductName, Quantity, Price ) and i have 4 colums in my dataGrid ( ProductName, Quantity, Price, Total(price*quantity)). I also have 2 bouton, (add product) which will add the textBox value to the DataGrid and a bouton (save) which will save the content of the dataGrid in a DataBase.

How should I proceed ?

Upvotes: 1

Views: 1557

Answers (1)

Vincent
Vincent

Reputation: 22944

The DataSource of the DataGrid should point to a collection of items.

Each row will be a single entity of your collection and it's properties can then be bound to a column (using templates).

See: Datagrid binding in WPF

Upvotes: 2

Related Questions