NZJames
NZJames

Reputation: 5055

wpf grid control for adding dynamic data

What is the WPF control I need if I want the user to be able to input Cross Ccy amounts, ie the data needed for each row is

Ccy One, Ccy Two, Amount

I want a grid-like control where the User can enter data for each cell in the row and once you begin to enter data in the cells, a new row gets added underneath, so the control keeps growing with every entry the user inputs and has no upper limit but grows to fit, using a scrollbar when it goes outside the bounds of the grid container.

Is there a built in control to do this? Or do I have to add functionality to listview/datagrid?

Upvotes: 0

Views: 224

Answers (2)

Omri Btian
Omri Btian

Reputation: 6547

If you want the user to be able to add new rows just set the CanUserAddRows property on the DataGrid to true.

<DataGrid CanUserAddRows="True" ..../>

If you want rows the be added when the user edits a data in a cell in an existing row, you can register to one of the cell edit events (depending when you want the new row to be added) and add rows to the grid or items to the collection it is binded to.

datagrid.CellEditEnding += (grid, args) =>
{
      datagrid.Items.Add( ....);
};

Upvotes: 1

Enhakiel
Enhakiel

Reputation: 316

this is the standard behavior of a datagrid, if the property CanUserAddRows is set to True

Upvotes: 0

Related Questions