Hi, guys. When I use ObservableCollection<T> as the data resource for DataGrid, I need to bind each column with a field and can set styles for the column as well. However, when use DataTable as the data resource for DataGrid, I just need to bind the DataTable with the DataGrid as below.
<DataGrid
Grid.Row="0"
x:Name="TransformLoadsDataGrid"
ItemsSource="{Binding TransformerLoads, UpdateSourceTrigger=PropertyChanged}"
CanUserAddRows="False"
CanUserSortColumns="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
GridLinesVisibility="All"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Visible"
RowHeaderWidth="0"
BorderBrush="Black"
BorderThickness="0 1 0 1"
Margin="0 0 0 10"
Background="{StaticResource CustomPureWhiteBrush}"
SelectedIndex="{Binding CurrentRowIndex, Mode=TwoWay}">
</DataGrid>
In this way, how could I set styles for columns? Such as text alignment or border styles?
Thanks in advance!