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!
Share
Let’s say
ItemsSourceof yourDataGridis a Collection ofSomeClassand you are displaying differentPropertiesofSomeClassin DataGrid Columns. What you can do is in constructor of defaultSomeClassassign thePropertiessome default value. In this way you can have default column value in DataGrid.Edit
As you said the
itemssourceof column is a string there is one way I can think of..Make it collection of
SomeClasswhich will only have astringproperty. In the default constructor ofSomeClassassign this string a default value. That default value will appear in your data grid column