<Window

 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

 x:Class="WpfApplication1.Window2"

 x:Name="Window"

 Title="Window2"

 Width="640" Height="480">

<Window.Resources>

 <Style TargetType="DataGrid">

        <!--网格线颜色-->

        <Setter Property="CanUserResizeColumns" Value="false"/>

        <Setter Property="Background" Value="#E6DBBB" />

        <Setter Property="BorderBrush" Value="#d6c79b" />

        <Setter Property="HorizontalGridLinesBrush">

            <Setter.Value>

                <SolidColorBrush Color="#d6c79b"/>

            </Setter.Value>

        </Setter>

        <Setter Property="VerticalGridLinesBrush">

            <Setter.Value>

                <SolidColorBrush Color="#d6c79b"/>

            </Setter.Value>

        </Setter>

    </Style>

<!--标题栏样式-->

    <!--<Style  TargetType="DataGridColumnHeader" >

        <Setter Property="Width" Value="50"/>

        <Setter Property="Height" Value="30"/>

        <Setter Property="FontSize" Value="14" />

        <Setter Property="Background" Value="White" />

        <Setter  Property="FontWeight"  Value="Bold"/>

    </Style>-->

<Style TargetType="DataGridColumnHeader">

        <Setter Property="SnapsToDevicePixels" Value="True" />

        <Setter Property="MinWidth" Value="0" />

        <Setter Property="MinHeight" Value="28" />

        <Setter Property="Foreground" Value="#323433" />

        <Setter Property="FontSize" Value="14" />

        <Setter Property="Cursor" Value="Hand" />

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="DataGridColumnHeader">

                    <Border x:Name="BackgroundBorder" BorderThickness="0,1,0,1"

                             BorderBrush="#e6dbba"

                              Width="Auto">

                        <Grid >

                            <Grid.ColumnDefinitions>

                                <ColumnDefinition Width="*" />

                            </Grid.ColumnDefinitions>

                            <ContentPresenter  Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>

                            <Path x:Name="SortArrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill"  Grid.Column="2" Width="8" Height="6" Fill="White" Margin="0,0,50,0"


                            VerticalAlignment="Center" RenderTransformOrigin="1,1" />

                            <Rectangle Width="1" Fill="#d6c79b" HorizontalAlignment="Right" Grid.ColumnSpan="1" />

                            <!--<TextBlock  Background="Red">

                            <ContentPresenter></ContentPresenter></TextBlock>-->

                        </Grid>

                    </Border>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

        <Setter Property="Height" Value="25"/>

    </Style>

    <!--行样式触发-->

    <!--背景色改变必须先设置cellStyle 因为cellStyle会覆盖rowStyle样式-->

    <Style  TargetType="DataGridRow">

        <Setter Property="Background" Value="#F2F2F2" />

        <Setter Property="Height" Value="25"/>

        <Setter Property="Foreground" Value="Black" />

        <Style.Triggers>

            <!--隔行换色-->

            <Trigger Property="AlternationIndex" Value="0" >

                <Setter Property="Background" Value="#e7e7e7" />

            </Trigger>

            <Trigger Property="AlternationIndex" Value="1" >

                <Setter Property="Background" Value="#f2f2f2" />

            </Trigger>

<Trigger Property="IsMouseOver" Value="True">

                <Setter Property="Background" Value="LightGray"/>

                <!--<Setter Property="Foreground" Value="White"/>-->

            </Trigger>

<Trigger Property="IsSelected" Value="True">

                <Setter Property="Foreground" Value="Black"/>

            </Trigger>

        </Style.Triggers>

    </Style>

<!--单元格样式触发-->

    <Style TargetType="DataGridCell">

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="DataGridCell">

                    <TextBlock TextAlignment="Center" VerticalAlignment="Center"  >

                           <ContentPresenter />

                    </TextBlock>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

        <Style.Triggers>

            <Trigger Property="IsSelected" Value="True">

                <!--<Setter Property="Background" Value="White"/>

                <Setter Property="BorderThickness" Value="0"/>-->

                <Setter Property="Foreground" Value="Black"/>

            </Trigger>

        </Style.Triggers>

    </Style>

</Window.Resources>

 <Grid x:Name="LayoutRoot">

        <DataGrid Margin="0" x:Name="dg_list"  AutoGenerateColumns="False">

   <DataGrid.Columns>

                            <DataGridTextColumn Header="名称" Width="150"  Binding="{Binding  Name}"/>

                            <DataGridTextColumn Header="最新价"   Width="120"  Binding="{Binding Zxj}"/>

                            <DataGridTextColumn Header="涨跌"  Width="120"  Binding="{Binding Zd}"/>

                            <DataGridTextColumn Header="涨幅"  Width="130"  Binding="{Binding Zf}"/>

                            <DataGridTextColumn Header="短线强势股"  Width="140"  Binding="{Binding Dxqsg}"/>

                        </DataGrid.Columns>

   

  </DataGrid>

 </Grid>

</Window>

最新文章

  1. 6款程序员不得不爱的bootstrap模板
  2. MVC API 权限控制
  3. mysql 事件调度
  4. supersr--NSURLConnection iOS2.0苹果原生请求
  5. javascript原型方法
  6. Jmeter—1 安装
  7. 织梦DedeCMS首页调用单页文档内容的方法
  8. poj 2739 Sum of Consecutive Prime Numbers 解题报告
  9. SOA之(2)——SOA架构基础概念与设计框架
  10. mahout算法源码分析之Itembased Collaborative Filtering(二)RowSimilarityJob
  11. A.prototype.b=22和A.b=22的区别
  12. PHP移动互联网开发笔记(5)——文件的上传下载
  13. temp-成都农商行路径
  14. day-6 机器学习概念及应用
  15. python del关键字的用法
  16. Android组件化、模块化、插件化
  17. Android Launcher分析和修改11——自定义分页指示器(paged_view_indicator)
  18. 洛谷 P4779 :【模板】单源最短路径(标准版)(Dijkstra+堆优化+链式前向星)
  19. 再读c++primer plus 001
  20. C# 如何实现邮件发送

热门文章

  1. UE4点选源码分析
  2. Docker部署Zookeeper部署实践(1)
  3. awk-03-操作符
  4. CVE-2020-2883漏洞复现&amp;&amp;流量分析
  5. 008 PCI设备BAR空间的初始化
  6. SQL 练习26
  7. flutter实现文字超出最大宽度显示省略号
  8. C# 检测某版本VC++是否安装
  9. C#中的信号量---Semaphore
  10. ajax传字符串时出现乱码问题的解决