I have a regular DataGrid from WPF 4.0 RTM where I put data from a database. To make the DataGrid look clean and light, I use tall / tall rows and by default, the DataGrid aligns the contents of the row in the upper vertical position, but I want to set the vertical alignment to the center.
I already tried to use this property
VerticalAlignment="Center"
in the DataGrid options, but that doesn't help me.
Here is an example of a XAML code describing my DataGrid without vertical center alignment:
<DataGrid x:Name="ContentDataGrid" Style="{StaticResource ContentDataGrid}" ItemsSource="{Binding}" RowEditEnding="ContentDataGrid_RowEditEnding"> <DataGrid.Columns> <DataGridTextColumn Header="UserID" Width="100" IsReadOnly="True" Binding="{Binding Path=userID}" /> <DataGridTextColumn Header="UserName" Width="100" Binding="{Binding Path=userName}" /> <DataGridTextColumn Header="UserAccessLevel" Width="100" Binding="{Binding Path=userAccessLevel}" /> <DataGridTextColumn Header="UserPassword" Width="*" Binding="{Binding Path=userPassword}" /> </DataGrid.Columns> </DataGrid>
The result of executing this code:

As you can see, the entire contents of the line has top vertical alignment.
What do I need to add to get the center alignment of each row content?
c # vertical-alignment wpf xaml datagrid
Mike B. Oct 20 '10 at 18:50 2010-10-20 18:50
source share