码迷,mamicode.com
首页 > Windows程序 > 详细

WPF DataGrid交替行样式

时间:2017-07-28 19:24:02      阅读:1083      评论:0      收藏:0      [点我收藏+]

标签:binding   color   static   source   alter   horizon   als   hang   lte   

 <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交替行样式

标签:binding   color   static   source   alter   horizon   als   hang   lte   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!