首页 > Windows开发 > 详细

WPF DataGrid交替行样式

时间:2017-07-28 19:14:17      阅读:272      评论:0      收藏:0      [点我收藏+]
 <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>

运行效果:

技术分享

 

WPF DataGrid交替行样式

原文:http://www.cnblogs.com/YYkun/p/7251773.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!