Reputation: 1725
I have a database application in which I display table with 5 columns in DataGrid
.
I'm using XAML
to create UI, and I have problem with setting the width of each column
.
I know I can use Propetries ColumnWidth
in DataGrid
but it sets width of all columns
.
How can I set the width for every single column
SEPARATELY?
Upvotes: 1
Views: 1517
Reputation: 33384
When you specify your own column layout then each DataGridColumn
has a Width
property. If you auto-generate column layout (AutoGenerateColumns=true
) then DataGrid
supports a DataGrid.AutoGeneratingColumn
event which gives you DataGridAutoGeneratingColumnEventArgs
data and you can access new column from there and set Width
, do other changes or cancel column creation altogether. DataGrid.AutoGeneratingColumn Event
Upvotes: 1
Reputation: 2875
Use the DataGrid.Columns
Property to define each column manually. Then you can define the Width
property for each column seperatly.
Refer to this article for examples: http://msdn.microsoft.com/de-de/library/system.windows.controls.datagrid.columns.aspx
Upvotes: 0