赞
踩
<ControlLibrary:DataGridEx x:Name="dgTable" HorizontalAlignment="Stretch" Style="{DynamicResource DataGridStyle}" > <DataGrid.ColumnHeaderStyle>//更改表格的标题行样式 <Style TargetType="DataGridColumnHeader"> <Setter Property="HorizontalContentAlignment" Value="Center" ></Setter>//居中 <Setter Property="FontSize" Value="15"></Setter>//字体大小 <Setter Property="Foreground" Value="#FFEBF5F5"></Setter> <Setter Property="Background" Value="#FF326DD4"></Setter> </Style> </DataGrid.ColumnHeaderStyle> <DataGrid.Columns> <DataGridTextColumn x:Name="columnHeader1" CanUserSort="False" Header="电池编号" Binding="{Binding BatteryOrder}" ElementStyle="{StaticResource DataGridTextCenter}" Width="*" > </DataGridTextColumn> <DataGridTextColumn x:Name="columnHeader2" CanUserSort="False" Header="开始电压" Binding="{Binding StartVoltage}" ElementStyle="{StaticResource DataGridTextCenter}" Width="*"/> <DataGridTextColumn x:Name="columnHeader3" CanUserSort="False" Header="终止电压" Binding="{Binding EndVoltage}" ElementStyle="{StaticResource DataGridTextCenter}" Width="*"/> <DataGridTextColumn x:Name="columnHeader4" CanUserSort="False" Header="电池内阻/mΩ" Binding="{Binding BatteryResistance}" ElementStyle="{StaticResource DataGridTextCenter}" Width="*"/> <!--<DataGridTextColumn x:Name="columnHeader5" CanUserSort="False" Header="实验结论" Binding="{Binding TestResult}" ElementStyle="{StaticResource DataGridTextCenter}"/>--> <!--<DataGridTextColumn Width="100" Header="维护方案" Binding="{Binding Maintenance}"/>--> <DataGridTextColumn x:Name="columnHeader5" CanUserSort="False" CanUserReorder="False" Header="实验结论" ElementStyle="{StaticResource DataGridTextCenter}" Width="*" > <DataGridTextColumn.Binding> <MultiBinding Converter="{StaticResource ResourceKey=DataReportTestResultConverter}"> <Binding Path="StartVoltage"/> <Binding Path="EndVoltage"/> <Binding Path="dicLanguages"/> </MultiBinding> </DataGridTextColumn.Binding> </DataGridTextColumn> <DataGridTextColumn x:Name="columnHeader6" CanUserSort="False" CanUserReorder="False" Header="维护方案" ElementStyle="{StaticResource DataGridTextCenter}" Width="*"> <DataGridTextColumn.Binding> <MultiBinding Converter="{StaticResource ResourceKey=DataReportMaintenanceConverter}"> <Binding Path="StartVoltage"/> <Binding Path="EndVoltage"/> </MultiBinding> </DataGridTextColumn.Binding> </DataGridTextColumn> </DataGrid.Columns> <DataGrid.CellStyle> //更改行的样式 <Style TargetType="{x:Type DataGridCell}"> //去掉单元格中间的竖线 <Style.Triggers> <Trigger Property="IsSelected" Value="False"> <Setter Property="BorderThickness" Value="0"/> </Trigger> <Trigger Property="IsSelected" Value="True"> <Setter Property="BorderThickness" Value="0"/> </Trigger> //根据数据源中TestResult列的的内容来显示相应的颜色 正常电池就是Orange 严重就是Red <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding TestResult}" Value=" 正常电池"/> </MultiDataTrigger.Conditions> <MultiDataTrigger.Setters> <Setter Property="Background" Value="Orange"/> </MultiDataTrigger.Setters> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding TestResult}" Value="严重劣化电池"/> </MultiDataTrigger.Conditions> <MultiDataTrigger.Setters> <Setter Property="Background" Value="red"/> </MultiDataTrigger.Setters> </MultiDataTrigger> </Style.Triggers> </Style> </DataGrid.CellStyle> </ControlLibrary:DataGridEx>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。