WPF DataGrid交替行样式

时间:2017-07-28 19:24:02   收藏:0   阅读:1083
 <DataGrid Grid.Row="0" RowHeaderWidth="0"  Name="dgvList" AlternationCount="2"  AutoGenerateColumns="False" FontSize="50" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True">
                    <DataGrid.ColumnHeaderStyle>
                        <Style TargetType="DataGridColumnHeader">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <ImageBrush/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Foreground" Value="White"/>
                            <Setter Property="FontSize" Value="50" />
                            <Setter Property="BorderBrush" Value="Blue" />
                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        </Style>
                    </DataGrid.ColumnHeaderStyle>
                    <DataGrid.Background>
                        <ImageBrush/>
                    </DataGrid.Background>
                    <DataGrid.RowStyle>
                        <Style TargetType="{x:Type DataGridRow}">
                            <Style.Triggers>
                                <Trigger Property="ItemsControl.AlternationIndex"  Value="0">
                                    <Setter Property="Background" Value="CornflowerBlue" />
                                </Trigger>
                                <Trigger Property="ItemsControl.AlternationIndex"  Value="1">
                                    <Setter Property="Background" Value="DeepSkyBlue" />
                                </Trigger>
                            </Style.Triggers>
                            <Setter Property="Foreground" Value="White"/>
                        </Style>
                    </DataGrid.RowStyle>

                    <DataGrid.Columns>
                        <DataGridTextColumn ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Header="检查室"  Binding="{Binding QUEUENAME, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="*"/>
                        <DataGridTextColumn ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Header="检查部位" Binding="{Binding PARTOFCHECK, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="*"/>
                        <DataGridTextColumn ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Header="当前就诊" Binding="{Binding NAME, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="*"/>
                        <DataGridTextColumn ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Header="准备就诊 " Binding="{Binding NAME2, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="*"/>
                    </DataGrid.Columns>
                </DataGrid>

运行效果:

技术分享

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!