Silverlight DataGrid 多重表头实现

Silverlight DataGrid 多重表头实现,第1张

概述<controls:ChildWindow x:Class="FXHS.ShowSSXQList" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<controls:ChilDWindow x:Class="FXHS.ShowSSXQList"           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"            xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"           xmlns:controls="clr-namespace:System.windows.Controls;assembly=System.windows.Controls"            title="实时险情列表" FontSize="15">    <!--定义资源样式-->    <controls:ChilDWindow.Resources>        <Style x:Key="DataGrIDheaderStyle" targettype="sdk:DataGrIDColumnheader">            <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>        </Style>        <Style x:Key="DataGrIDCellStyle" targettype="sdk:DataGrIDCell">            <Setter Property="HorizontalContentAlignment" Value="Center" ></Setter>        </Style>        <Style x:Key="DataGrIDBaseheaderStyle" targettype="sdk:DataGrIDColumnheader">            <Setter Property="FontWeight" Value="normal" />        </Style>        <Style x:Key="TimeSheetDayheaderStyle" targettype="sdk:DataGrIDColumnheader" BasedOn="{StaticResource DataGrIDBaseheaderStyle}">            <Setter Property="Foreground" Value="#FF000000"/>            <Setter Property="HorizontalContentAlignment" Value="left"/>            <Setter Property="VerticalContentAlignment" Value="Center"/>            <Setter Property="IsTabStop" Value="False"/>            <Setter Property="SeparatorBrush" Value="#FFC9CACA"/>            <Setter Property="padding" Value="8"/>            <Setter Property="Template">                <Setter.Value>                    <ControlTemplate>                        <GrID x:name="Root">                            <GrID.ColumnDeFinitions>                                <ColumnDeFinition/>                                <ColumnDeFinition WIDth="auto"/>                            </GrID.ColumnDeFinitions>                            <visualstatemanager.VisualStateGroups>                                <VisualStateGroup x:name="CommonStates">                                    <VisualState x:name="normal"/>                                    <VisualState x:name="MouSEOver">                                        <Storyboard>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundRectangle"                                                    Storyboard.TargetProperty="(Fill).color" To="#FF448DCA"/>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundGradIEnt"                                                    Storyboard.TargetProperty="(Fill).(GradIEntStops)[3].color" To="#7FFFFFFF"/>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundGradIEnt"                                                    Storyboard.TargetProperty="(Fill).(GradIEntStops)[2].color" To="#CCFFFFFF"/>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundGradIEnt"                                                    Storyboard.TargetProperty="(Fill).(GradIEntStops)[1].color" To="#F2FFFFFF"/>                                        </Storyboard>                                    </VisualState>                                    <VisualState x:name="pressed">                                        <Storyboard>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundRectangle"                                                    Storyboard.TargetProperty="(Fill).color" To="#FF448DCA"/>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundGradIEnt"                                                    Storyboard.TargetProperty="(Fill).(GradIEntStops)[0].color" To="#D8FFFFFF"/>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundGradIEnt"                                                    Storyboard.TargetProperty="(Fill).(GradIEntStops)[1].color" To="#C6FFFFFF"/>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundGradIEnt"                                                    Storyboard.TargetProperty="(Fill).(GradIEntStops)[2].color" To="#8CFFFFFF"/>                                            <colorAnimation Duration="0"                                                    Storyboard.Targetname="BackgroundGradIEnt"                                                    Storyboard.TargetProperty="(Fill).(GradIEntStops)[3].color" To="#3FFFFFFF"/>                                        </Storyboard>                                    </VisualState>                                </VisualStateGroup>                                <VisualStateGroup x:name="SortStates">                                    <VisualState x:name="Unsorted"/>                                    <VisualState x:name="SortAscending" />                                    <VisualState x:name="SortDescending" />                                </VisualStateGroup>                            </visualstatemanager.VisualStateGroups>                            <Rectangle x:name="BackgroundRectangle" Fill="#FF1F3B53" Stretch="Fill" GrID.ColumnSpan="2"/>                            <Rectangle x:name="BackgroundGradIEnt" Stretch="Fill" GrID.ColumnSpan="2">                                <Rectangle.Fill>                                    <linearGradIEntBrush EndPoint=".7,1" StartPoint=".7,0">                                        <GradIEntStop color="#FCFFFFFF" Offset="0.015"/>                                        <GradIEntStop color="#F7FFFFFF" Offset="0.375"/>                                        <GradIEntStop color="#E5FFFFFF" Offset="0.6"/>                                        <GradIEntStop color="#D1FFFFFF" Offset="1"/>                                    </linearGradIEntBrush>                                </Rectangle.Fill>                            </Rectangle>                            <GrID HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}">                                <GrID.RowDeFinitions>                                    <RowDeFinition Height="20" />                                    <RowDeFinition Height="1" />                                    <RowDeFinition Height="20" />                                </GrID.RowDeFinitions>                                <GrID.ColumnDeFinitions>                                    <ColumnDeFinition WIDth="100"/>                                    <ColumnDeFinition WIDth="1" />                                    <ColumnDeFinition WIDth="299"/>                                    <ColumnDeFinition WIDth="1" />                                    <ColumnDeFinition WIDth="199"/>                                </GrID.ColumnDeFinitions>                                <!-- 第0行 -->                                <ContentPresenter Content="险情类型" GrID.Row="0" VerticalAlignment="Center"                                          HorizontalAlignment="Center" />                                <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" WIDth="1"                                    Visibility="Visible" GrID.Row="0" GrID.Column="1" />                                <ContentPresenter Content="险情标题" GrID.Row="0" GrID.Column="2"                                          VerticalAlignment="Center" HorizontalAlignment="Center" />                                <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" WIDth="1"                                    Visibility="Visible" GrID.Row="0" GrID.Column="3" />                                <ContentPresenter Content="上传时间" GrID.Row="0" GrID.Column="4"                                          VerticalAlignment="Center" HorizontalAlignment="Center" />                                <!-- 第一行 -->                                <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" Height="1"                                   Visibility="Visible" GrID.Row="1" GrID.ColumnSpan="5" />                                <!-- 第二行 -->                                <ContentPresenter Content="险情描述"                                          VerticalAlignment="Center" HorizontalAlignment="Center"                                          GrID.ColumnSpan="5" GrID.Row="2" />                            </GrID>                            <Rectangle x:name="VerticalSeparator" Fill="#FFC9CACA"                               VerticalAlignment="Stretch" WIDth="1" Visibility="Visible"                               GrID.Row="1" GrID.Column="1"/>                        </GrID>                    </ControlTemplate>                </Setter.Value>            </Setter>        </Style>        <Style x:Key="TimeSheetTotalsheaderStyle" targettype="sdk:DataGrIDColumnheader" BasedOn="{StaticResource TimeSheetDayheaderStyle}">            <Setter Property="Foreground" Value="#FFFF0000"/>        </Style>    </controls:ChilDWindow.Resources>    <GrID x:name="LayoutRoot" margin="0" Height="400">        <GrID.RowDeFinitions>            <RowDeFinition />            <RowDeFinition Height="auto" />        </GrID.RowDeFinitions>        <GrID x:name="gtop" Height="31" VerticalAlignment="top"/>        <GrID x:name="gMIDdle" margin="0,31,25">            <sdk:DataGrID margin="0" autoGenerateColumns="False" x:name="dg" LoadingRow="dg_LoadingRow">                <sdk:DataGrID.Columns>                    <sdk:DataGrIDTemplateColumn header="序号" headerStyle="{StaticResource DataGrIDheaderStyle}" WIDth="60">                        <sdk:DataGrIDTemplateColumn.CellTemplate>                            <DataTemplate>                                <TextBlock FontSize="13" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>                            </DataTemplate>                        </sdk:DataGrIDTemplateColumn.CellTemplate>                    </sdk:DataGrIDTemplateColumn>                    <sdk:DataGrIDTemplateColumn header="图片" headerStyle="{StaticResource DataGrIDheaderStyle}" WIDth="200">                        <sdk:DataGrIDTemplateColumn.CellTemplate>                            <DataTemplate>                                <GrID>                                    <Image x:name="Image1" Source="{Binding 图片}"></Image>                                </GrID>                            </DataTemplate>                        </sdk:DataGrIDTemplateColumn.CellTemplate>                    </sdk:DataGrIDTemplateColumn>                    <sdk:DataGrIDTemplateColumn header="险情描述" headerStyle="{StaticResource TimeSheetDayheaderStyle}">                        <sdk:DataGrIDTemplateColumn.CellTemplate>                            <DataTemplate>                                <GrID>                                    <GrID.RowDeFinitions>                                        <RowDeFinition Height="0.2*"></RowDeFinition>                                        <RowDeFinition Height="1"></RowDeFinition>                                        <RowDeFinition Height="*"></RowDeFinition>                                    </GrID.RowDeFinitions>                                    <GrID.ColumnDeFinitions>                                        <ColumnDeFinition  WIDth="100"></ColumnDeFinition>                                        <ColumnDeFinition WIDth="1"></ColumnDeFinition>                                        <ColumnDeFinition WIDth="290"></ColumnDeFinition>                                        <ColumnDeFinition  WIDth="1"></ColumnDeFinition>                                        <ColumnDeFinition WIDth="199"></ColumnDeFinition>                                    </GrID.ColumnDeFinitions>                                    <TextBlock Text="{Binding 灾情类型}" FontSize="14" HorizontalAlignment="Center" GrID.Row="0" GrID.Column="0"/>                                    <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" WIDth="1" GrID.Row="0" GrID.Column="1"/>                                    <TextBlock Text="{Binding 图片标题}" HorizontalAlignment="Center" FontSize="14" margin="2,0" GrID.Row="0" GrID.Column="2"/>                                    <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" WIDth="1" GrID.Row="0" GrID.Column="3"/>                                    <TextBlock Text="{Binding 上传时间}" FontSize="14" HorizontalAlignment="Center" margin="2,0" GrID.Row="0" GrID.Column="4"/>                                    <!--内容行之间的横线-->                                    <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" Height="1"                                   Visibility="Visible" GrID.Row="1" GrID.ColumnSpan="5" />                                    <TextBlock Text="{Binding 备注}" FontSize="14" GrID.Row="2" GrID.Column="0" GrID.ColumnSpan="5" textwrapPing="Wrap"></TextBlock>                                </GrID>                            </DataTemplate>                        </sdk:DataGrIDTemplateColumn.CellTemplate>                    </sdk:DataGrIDTemplateColumn>                </sdk:DataGrID.Columns>            </sdk:DataGrID>        </GrID>        <GrID x:name="gBottom" VerticalAlignment="Bottom">            <sdk:DataPager x:name="DataPager1" PageIndexChanged="DataPager1_PageIndexChanged" Height="24" PageSize="4" displayMode="FirstLastPrevIoUsNext" VerticalAlignment="Bottom" margin="0"/>        </GrID>    </GrID></controls:ChilDWindow>


如下界面

总结

以上是内存溢出为你收集整理的Silverlight DataGrid 多重表头实现全部内容,希望文章能够帮你解决Silverlight DataGrid 多重表头实现所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1072243.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存