DataGridColumn类型的继承树 DataGridColumn的派生类: 一般情况下DataGridBoundColumn和DataGridComboBoxColumn足以满足多数列的样式,如果需要自定义列样式,则可以使用DataGridTemplateColumn类型
<DataGrid x:Name="mygrid" VerticalAlignment="Top" AutoGenerateColumns="False" Foreground="White" Background="Transparent" Margin="0,20,0,0"
RowBackground="Transparent" GridLinesVisibility="All" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" BorderBrush="Transparent"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="14.5" RowHeaderWidth="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"
EnableColumnVirtualization="True" EnableRowVirtualization="True" ItemsSource="{Binding UnitHost}" ColumnHeaderStyle="{StaticResource ParkColumnHeader}">
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Yellow"/>
</DataGrid.Resources>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Height" Value="40"></Setter>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="停车场名称" Width="200" Binding="{Binding name}" ElementStyle="{StaticResource ResourceKey=DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Header="已使用" Width="110" Binding="{Binding used}" ElementStyle="{StaticResource ResourceKey=DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Header="未使用" Width="110" Binding="{Binding notused}" ElementStyle="{StaticResource ResourceKey=DataGridTextColumnCenterSytle}"/>
<DataGridTemplateColumn Header="使用占比" Width="200" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ProgressBar Value="{Binding ratio}" Background="#4C717171" BorderBrush="Transparent" Height="20"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header=" " Width="80" Binding="{Binding ratioValue}" Foreground="#ec6941" ElementStyle="{StaticResource ResourceKey=DataGridTextColumnCenterSytle}"/>
</DataGrid.Columns>
</DataGrid>