DataGrid添加進度條列
阿新 • • 發佈:2019-05-16
enable nes mco ems alc resource align lin sed
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>
DataGrid添加進度條列