I have a DataGrid in my WPF application. I was wondering if there is a way to show default values for a column in the datagrid. For example, I let the user have the ability to add new rows to the DataGrid. Hence, at the bottom of the DataGrid, there is always a blank, empty row for the user to add data to. I was hoping to have a default value for a column in this row. Is there any way to achieve this functionality? Thanks!
Let's say ItemsSource
of your DataGrid
is a Collection of SomeClass
and you are displaying different Properties
of SomeClass
in DataGrid Columns. What you can do is in constructor of default SomeClass
assign the Properties
some default value. In this way you can have default column value in DataGrid.
Edit
As you said the itemssource
of column is a string there is one way I can think of..
Make it collection of SomeClass
which will only have a string
property. In the default constructor of SomeClass
assign this string a default value. That default value will appear in your data grid column