- 因为第一次使用c1 for wpf的FlexGrid和DataGrid控件,所以有很多地方不太熟悉,在社区里请教了无数次alice版主,在此表示由衷的感谢!
DataGrid及FlexGrid区别以及选择:
DataGrid以及FlexGrid都可以做到列标题合并,都可以做到合计。
不同之处,泛泛而言,FlexGrid小巧灵活、不限于绑定亦可后台灵活操作;DataGrid基于Wpf原有DataGrid,基于绑定。
两个控件的应用场景可以参考中文官网。
C1FlexGrid: http://www.gcpowertools.com.cn/p ... onewpf/flexgrid.htm
C1DataGrid: http://www.gcpowertools.com.cn/p ... onewpf/datagrid.htm
两个component美国论坛里的2个链接:
http://our.componentone.com/grou ... is-more-performant/
http://our.componentone.com/grou ... exgrid-or-datagrid/
列标题合并及冻结:
DataGrid以及FlexGrid都可以做到列标题合并,但合并的方式不同(也许我仅知道这些方式)
DataGrid合并:- <c1:DataGridRowHeaderColumn Header="[生产厂区, 基本信息, 基本信息]"
- Width="Auto" />
- <c1:DataGridRowHeaderColumn Header="[生产厂区,生产设备, 生产机长]"
- Width="Auto" />
- <c1:DataGridRowHeaderColumn Header="[生产厂区,生产设备, 生产机台]"
- Width="Auto" />
- <c1:DataGridRowHeaderColumn Header="[目标产量, 目标产量, 目标产量]"
- Width="Auto" />
- <!-- First two columns must be headers, put several headers using this custom syntax-->
- <c1:DataGridTextColumn Header="[Country, Continent, 1]" />
- <c1:DataGridTextColumn Header="[Country, Name, 1]" />
复制代码
在后台代码中具体代码参见:
以上示例为版主Alice所做,如果遇到全部或者部分没有合并的时候,注意一下代码:
- // save headers rows and columns for later
- _headerRowColumns = grid.Columns.Take(3).ToArray();
- _headerColumnRows = grid.TopRows.Take(3).ToArray();
复制代码
FlexGrid合并:
- FlexGrid.ColumnHeaders.Rows.Add(new Row());
- FlexGrid.ColumnHeaders.Rows.Add(new Row());
- FlexGrid.ColumnHeaders.Rows[0][0] = "生产厂区";
- FlexGrid.ColumnHeaders.Rows[1][0] = "生产厂区";
- FlexGrid.ColumnHeaders.Rows[2][0] = "生产厂区";
- FlexGrid.ColumnHeaders.Columns[0].AllowMerging = true;
- FlexGrid.AllowMerging = AllowMerging.All;
复制代码
其中冻结列,只有DataGrid有可拖动的冻结分割线,如下图:
合计:
DataGrid:
- <c1:DataGridBoundColumn Header="开机天数" Binding="{Binding 开机天数}">
- <c1:DataGridAggregate.AggregateFunctions>
- <c1:DataGridAggregatesCollection>
- <c1:DataGridAggregateSum ></c1:DataGridAggregateSum>
- </c1:DataGridAggregatesCollection>
- </c1:DataGridAggregate.AggregateFunctions>
- </c1:DataGridBoundColumn>
复制代码
以上合计的格式无需特殊设置,会根据列的格式而随之而变。如果想加字符,可以ResultFormat="合计= {0}" ;
FlexGrid:
- <c1:C1FlexGrid.ColumnFooterRows>
- <c1:GroupRow FontWeight="Bold" FontSize="16" />
- </c1:C1FlexGrid.ColumnFooterRows>
复制代码
设置columnheader列头为透明色的问题。
由于backgroud 使用了C1brushbuilder,只能把整个DataGridColumnHeaderPresenter重写来实现透明的效果。具体代码如下(或者直接运行3中提到的示例即可):
- <c1:C1DataGrid.ColumnHeaderStyle>
- <Style TargetType="c1:DataGridColumnHeaderPresenter">
- <Setter Property="HorizontalContentAlignment" Value="Stretch" />
- <Setter Property="VerticalContentAlignment" Value="Stretch" />
- <Setter Property="BorderThickness" Value="0 0 1 1" />
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="c1:DataGridColumnHeaderPresenter">
- <Grid x:Name="RootElement">
- <Grid.Resources>
- <Color x:Key="BaseColor">#FFD1DCE8</Color>
- <SolidColorBrush x:Key="BaseColorBrush" Color="{StaticResource BaseColor}" />
- <!-- Color & Brush used to build brushes on MouseOver state -->
- <Color x:Key="MouseOverColor">#FFBFE1EA</Color>
- <SolidColorBrush x:Key="MouseOverBrush" Color="{StaticResource MouseOverColor}" />
- <!-- Color & Brush used to build brushes on Pressed and Checked states -->
- <Color x:Key="SelectedColor">#FF8ED1E2</Color>
- <SolidColorBrush x:Key="SelectedBackground" Color="{StaticResource SelectedColor}" />
- <!-- Brush used to build brushes on Focused states -->
- <SolidColorBrush x:Key="FocusBrush" Color="{StaticResource SelectedColor}" />
- <!-- Color & Brush @ general borders -->
- <Color x:Key="BorderColor">#FFA4AFBA</Color>
- <!-- Brush @ general borders -->
- <SolidColorBrush x:Key="BorderBrush" Color="{StaticResource BorderColor}" />
- <!-- Color & Brush @ general foreground -->
- <Color x:Key="ForegroundColor">Black</Color>
- <SolidColorBrush x:Key="ForegroundBrushColor" Color="{StaticResource ForegroundColor}" />
- <!-- Color & Brush @ TextBox foreground -->
- <Color x:Key="ForegroundTextBoxColor">Black</Color>
- <SolidColorBrush x:Key="ForegroundTextBoxBrushColor" Color="{StaticResource ForegroundTextBoxColor}" />
- <LinearGradientBrush x:Key="DataGridColumnHeaderBrush" StartPoint="0.5,0" EndPoint="0.5,1">
- <GradientStop Color="#FFEFF3F7" Offset="0" />
- <GradientStop Color="#FFE6ECF3" Offset="0.5" />
- <GradientStop Color="#FFD3DEEA" Offset="0.5" />
- <GradientStop Color="#FFC4D2E2" Offset="1" />
- </LinearGradientBrush>
- <LinearGradientBrush x:Key="DataGridColumnHeaderOverBrush" StartPoint="0.5,0" EndPoint="0.5,1">
- <GradientStop Color="#FFEDF6F9" Offset="0" />
- <GradientStop Color="#FFE4F2F6" Offset="0.5" />
- <GradientStop Color="#FFD2E9F0" Offset="0.5" />
- <GradientStop Color="#FFC0E0EA" Offset="1" />
- </LinearGradientBrush>
- <LinearGradientBrush x:Key="DataGridColumnHeaderSelectedBackground" StartPoint="0.5,0" EndPoint="0.5,1">
- <GradientStop Color="#FFA6D9E7" Offset="0" />
- <GradientStop Color="#FFA6D9E7" Offset="0.5" />
- <GradientStop Color="#FF93D1E2" Offset="0.5" />
- <GradientStop Color="#FF7BC7DC" Offset="1" />
- </LinearGradientBrush>
- <!-- Brush @ C1DataGrid ColumnHeader Sort Icon Background-->
- <SolidColorBrush x:Key="DataGridColumnHeaderSortBrush" Color="#FF5E5E5E" />
- <!-- Style @ C1DataGrid ColumnHeader Sort Icon -->
- <Style x:Key="DataGridColumnHeaderSortArrowStyle" TargetType="Path">
- <Setter Property="Height" Value="4" />
- <Setter Property="Width" Value="7" />
- <Setter Property="VerticalAlignment" Value="Top" />
- <Setter Property="HorizontalAlignment" Value="Center" />
- <Setter Property="Margin" Value="0,0.5,0,0" />
- <Setter Property="Visibility" Value="Collapsed" />
- </Style>
- <!-- Sort ToggleButton @ C1DataGrid ColumnHeader -->
- <Style x:Key="DataGridColumnHeaderSortTButtonStyle" TargetType="ToggleButton">
- <Setter Property="Padding" Value="3" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ToggleButton">
- <Grid>
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="CommonStates">
- <VisualState x:Name="Normal" />
- <VisualState x:Name="MouseOver" />
- <VisualState x:Name="Pressed" />
- <VisualState x:Name="Disabled" />
- </VisualStateGroup>
- <VisualStateGroup x:Name="CheckStates">
- <VisualState x:Name="Indeterminate" />
- <VisualState x:Name="Checked">
- <Storyboard>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SortbyElement" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
- <DiscreteObjectKeyFrame KeyTime="00:00:00">
- <DiscreteObjectKeyFrame.Value>
- <Visibility>Visible</Visibility>
- </DiscreteObjectKeyFrame.Value>
- </DiscreteObjectKeyFrame>
- </ObjectAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="Unchecked">
- <Storyboard>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="SortbyElement" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
- <SplineDoubleKeyFrame KeyTime="00:00:00" Value="180" />
- </DoubleAnimationUsingKeyFrames>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SortbyElement" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
- <DiscreteObjectKeyFrame KeyTime="00:00:00">
- <DiscreteObjectKeyFrame.Value>
- <Visibility>Visible</Visibility>
- </DiscreteObjectKeyFrame.Value>
- </DiscreteObjectKeyFrame>
- </ObjectAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- </VisualStateGroup>
- <VisualStateGroup x:Name="FocusStates">
- <VisualState x:Name="Focused" />
- <VisualState x:Name="Unfocused" />
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <c1:C1BrushBuilder x:Name="SortbyElementBrush" Input="{TemplateBinding Foreground}" DesignBrush="{StaticResource DataGridColumnHeaderSortBrush}" DesignColor="{StaticResource ForegroundColor}" />
- <Path x:Name="SortbyElement" Data="M0,0 L7,0 L3.5,4 L3.5,4 z" Fill="{Binding Output, ElementName=SortbyElementBrush}" Style="{StaticResource DataGridColumnHeaderSortArrowStyle}" Stretch="None" RenderTransformOrigin="0.5,0.5" Grid.Row="1" Opacity="0.6">
- <Path.RenderTransform>
- <TransformGroup>
- <ScaleTransform />
- <SkewTransform />
- <RotateTransform />
- <TranslateTransform />
- </TransformGroup>
- </Path.RenderTransform>
- </Path>
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- Brush @ C1DataGrid ColumnHeader Icon Background -->
- <SolidColorBrush x:Key="DataGridColumnHeaderIconBrush" Color="#FF5E5E5E" />
- <!-- Brush @ C1DataGrid ColumnHeader Icon Border -->
- <LinearGradientBrush x:Key="DataGridColumnHeaderIconBorderBrush" EndPoint="1,0" StartPoint="0,0">
- <GradientStop Color="#FF333333" Offset="0" />
- <GradientStop Color="#FF222222" Offset="0.496" />
- <GradientStop Color="#FF3B3B3B" Offset="0.5" />
- <GradientStop Color="#FF3B3B3B" Offset="1" />
- </LinearGradientBrush>
- <!-- Brush used to build brushes on MouseOver state -->
- <SolidColorBrush x:Key="DataGridMouseOverBrush" Color="#99BFE5EA" />
- <!-- Brush used to build brushes on Pressed, Checked and Focused states -->
- <SolidColorBrush x:Key="DataGridSelectedBackground" Color="#CC8ED1E2" />
- <!-- Brush @ C1DataGrid ColumnHeader Merging Background -->
- <SolidColorBrush x:Key="DataGridColumnHeaderMergingBrush" Color="#FFE3EAF1" />
- <!-- Brush @ C1DataGrid ColumnHeader Merging Background on MouseOver-->
- <SolidColorBrush x:Key="DataGridColumnHeaderMergingOverBrush" Color="#FFC6EBF4" />
- <!-- Brush @ C1DataGrid ColumnHeader Merging Selected Background-->
- <SolidColorBrush x:Key="DataGridColumnHeaderMergingSelectedBrush" Color="#FFA4DEED" />
- <!-- Brush @ C1DataGrid Main PanelBackground -->
- <SolidColorBrush x:Key="DataGridMainPanelBrush" Color="White" />
- <!-- Brush @ C1DataGrid BorderBrush -->
- <SolidColorBrush x:Key="DataGridBorderBrush" Color="#FFB0BDCA" />
- <!--Thickness @ C1DataGrid -->
- <Thickness x:Key="DataGridBorderThickness">1</Thickness>
- <!--CornerRadius @ C1DataGrid -->
- <CornerRadius x:Key="DataGridCornerRadius">0 0 0 0</CornerRadius>
- <!-- Brush @ C1DataGrid Horizontal & Vertical GridLines -->
- <SolidColorBrush x:Key="DataGridLinesBrush" Color="#FFCDD5DC" />
- <!-- Brush @ C1DataGrid Row -->
- <SolidColorBrush x:Key="DataGridRowBrush" Color="White" />
- <!-- Brush @ C1DataGrid Alternating Row -->
- <SolidColorBrush x:Key="DataGridAlternatingRowBrush" Color="#FFF3F6F9" />
- <!-- Brush @ C1DataGrid Foreground -->
- <SolidColorBrush x:Key="DataGridForeground" Color="{StaticResource ForegroundColor}" />
- <!-- Brush @ C1DataGrid Row Foreground -->
- <SolidColorBrush x:Key="DataGridRowForeground" Color="{StaticResource ForegroundTextBoxColor}" />
- <!-- Brush @ C1DataGrid Alternating Row Foreground -->
- <SolidColorBrush x:Key="DataGridAlternatingRowForeground" Color="{StaticResource ForegroundTextBoxColor}" />
- <!-- CornerRadius @ C1DataGrid -->
- <CornerRadius x:Key="DataGridGeneralCornerRadius">0</CornerRadius>
- <!-- Brush @ C1DataGrid bottom right corner -->
- <LinearGradientBrush x:Key="DataGridBottomRightCornerBrush" EndPoint="0.5,1" StartPoint="0.5,0">
- <GradientStop Color="#FFD1DCE8" Offset="1" />
- </LinearGradientBrush>
- <!-- CornerRadius @ C1DataGrid bottom right corner -->
- <CornerRadius x:Key="DataGridBottomRightCornerRadius">0 0 0 0</CornerRadius>
- <!-- Brush @ C1DataGrid top left corner -->
- <RadialGradientBrush x:Key="DataGridTopLeftCornerBrush">
- <RadialGradientBrush.RelativeTransform>
- <TransformGroup>
- <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.984" ScaleY="1.984" />
- <SkewTransform CenterX="0.5" CenterY="0.5" />
- <RotateTransform CenterX="0.5" CenterY="0.5" />
- <TranslateTransform X="0.502" Y="0.508" />
- </TransformGroup>
- </RadialGradientBrush.RelativeTransform>
- <GradientStop Color="#FFD1DCE8" Offset="1" />
- </RadialGradientBrush>
- <!-- Brush @ C1DataGrid top left corner on MouseOver -->
- <RadialGradientBrush x:Key="DataGridTopLeftCornerOverBrush">
- <RadialGradientBrush.RelativeTransform>
- <TransformGroup>
- <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.984" ScaleY="1.984" />
- <SkewTransform CenterX="0.5" CenterY="0.5" />
- <RotateTransform CenterX="0.5" CenterY="0.5" />
- <TranslateTransform X="0.502" Y="0.508" />
- </TransformGroup>
- </RadialGradientBrush.RelativeTransform>
- <GradientStop Color="#FFBFE1EA" Offset="1" />
- </RadialGradientBrush>
- <!-- CornerRadius @ C1DataGrid top left corner-->
- <CornerRadius x:Key="DataGridTopLeftCornerRadius">0 0 0 0</CornerRadius>
- <!-- Thickness @ C1DataGrid top left corner-->
- <Thickness x:Key="DataGridTopLeftBorderThickness">0 0 1 1</Thickness>
- <!-- WPF Input Brushes -->
- <SolidColorBrush x:Key="WpfInputDataGridBorderBrush" Color="#FF919191" />
- <SolidColorBrush x:Key="WpfInputDataGridLinesBrush" Color="#FFD3D3D3" />
- <SolidColorBrush x:Key="WpfInputDataGridMouseOverBrush" Color="#99BDE6FD" />
- <SolidColorBrush x:Key="WpfInputDataGridSelectedBackground" Color="#CCA9DAF3" />
- <!--******************** Row Presenter ********************-->
- <!-- Brush @ C1DataGrid Row Presenter Background on MouseOver -->
- <SolidColorBrush x:Key="DataGridRowOverBrush" Color="#FFBBDFE9" />
- <!-- Brush @ C1DataGrid Row Presenter Selected Background -->
- <SolidColorBrush x:Key="DataGridRowSelectedBackground" Color="#FFA4DEED" />
- <!--******************** Filters ********************-->
- <!-- Brush @ C1DataGrid Filter Background -->
- <LinearGradientBrush x:Key="DataGridFilterBrush" EndPoint="0.5,1" StartPoint="0.5,0">
- <GradientStop Color="#FFEEF2F6" Offset="0.8" />
- <GradientStop Color="#FFD0DBE7" Offset="1" />
- </LinearGradientBrush>
- <!-- Brush @ C1DataGrid Filter Content Background -->
- <LinearGradientBrush x:Key="DataGridFilterContentBrush" EndPoint="0.5,1" StartPoint="0.5,0">
- <GradientStop Color="#FFC8C4E1" Offset="0.7" />
- </LinearGradientBrush>
- <!-- CornerRadius @ C1DataGrid Filter -->
- <CornerRadius x:Key="DataGridFilterCornerRadius">0 0 2 2</CornerRadius>
-
- <!-- C1DropDown @ C1DataGrid Options -->
- <ControlTemplate x:Key="DataGridColumnHeaderOptionsDDownStyle" TargetType="c1:C1DropDown">
- <Grid>
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="DropDownOpenStates">
- <VisualState x:Name="Closed">
- <Storyboard />
- </VisualState>
- <VisualState x:Name="Opened" />
- </VisualStateGroup>
- <VisualStateGroup x:Name="CommonStates">
- <VisualState x:Name="Normal" />
- <VisualState x:Name="Disabled" />
- <VisualState x:Name="MouseOver" />
- </VisualStateGroup>
- <VisualStateGroup x:Name="FocusStates">
- <VisualState x:Name="Unfocused" />
- <VisualState x:Name="Focused">
- <Storyboard />
- </VisualState>
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <ToggleButton x:Name="ArrowToggle" Width="14" IsEnabled="{TemplateBinding IsEnabled}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" Style="{StaticResource DataGridColumnHeaderOptionsTButtonStyle}" c1:ClearStyleExtensions.MouseOverBrush="{TemplateBinding MouseOverBrush}" c1:ClearStyleExtensions.PressedBrush="{TemplateBinding PressedBrush}" IsTabStop="False" Content="{TemplateBinding Header}" />
- <Popup x:Name="DropDownPopup" VerticalAlignment="Bottom">
- <ContentPresenter />
- </Popup>
- </Grid>
- </ControlTemplate>
- <!-- Style @ C1DataGrid ColumnHeader Filter Icon -->
- <Style x:Key="DataGridColumnHeaderFilterIconStyle" TargetType="Path">
- <Setter Property="Stretch" Value="None" />
- <Setter Property="Height" Value="8" />
- <Setter Property="Width" Value="8" />
- <Setter Property="StrokeThickness" Value="1" />
- <Setter Property="Opacity" Value="0.6" />
- </Style>
- <!-- Style @ C1DataGrid ColumnHeader Options Icon -->
- <Style x:Key="DataGridColumnHeaderOptionsIconStyle" TargetType="Polygon">
- <Setter Property="Width" Value="7" />
- <Setter Property="StrokeThickness" Value="1" />
- <Setter Property="Opacity" Value="0.6" />
- </Style>
- </Grid.Resources>
- <VisualStateManager.VisualStateGroups>
- <VisualStateGroup x:Name="CommonStates">
- <VisualState x:Name="Normal" />
- <VisualState x:Name="Disabled" />
- <VisualState x:Name="MouseOver">
- <Storyboard>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
- <DiscreteObjectKeyFrame KeyTime="00:00:00">
- <DiscreteObjectKeyFrame.Value>
- <Visibility>Visible</Visibility>
- </DiscreteObjectKeyFrame.Value>
- </DiscreteObjectKeyFrame>
- </ObjectAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- </VisualStateGroup>
- <VisualStateGroup x:Name="SelectionStates">
- <VisualState x:Name="Selected">
- <Storyboard>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
- <DiscreteObjectKeyFrame KeyTime="00:00:00">
- <DiscreteObjectKeyFrame.Value>
- <Visibility>Visible</Visibility>
- </DiscreteObjectKeyFrame.Value>
- </DiscreteObjectKeyFrame>
- </ObjectAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="Editing">
- <Storyboard>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SelectedElement" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
- <DiscreteObjectKeyFrame KeyTime="00:00:00">
- <DiscreteObjectKeyFrame.Value>
- <Visibility>Visible</Visibility>
- </DiscreteObjectKeyFrame.Value>
- </DiscreteObjectKeyFrame>
- </ObjectAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="Unselected">
- <Storyboard />
- </VisualState>
- </VisualStateGroup>
- <VisualStateGroup x:Name="OptionsStates">
- <VisualState x:Name="Filtering">
- <Storyboard>
- <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OptionsArrow" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0">
- <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="0" />
- </DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Filter" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0">
- <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value=".6" />
- </DoubleAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="Undefined">
- <Storyboard>
- <DoubleAnimationUsingKeyFrames Storyboard.TargetName="OptionsArrow" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0">
- <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="1" />
- </DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Filter" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0">
- <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="0" />
- </DoubleAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- </VisualStateGroup>
- <VisualStateGroup x:Name="MergingStates">
- <VisualState x:Name="Merging">
- <Storyboard>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundBrush" Storyboard.TargetProperty="DesignBrush">
- <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DataGridColumnHeaderMergingBrush}" />
- </ObjectAnimationUsingKeyFrames>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverBrush" Storyboard.TargetProperty="DesignBrush">
- <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DataGridColumnHeaderMergingOverBrush}" />
- </ObjectAnimationUsingKeyFrames>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="DesignBrush">
- <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DataGridColumnHeaderMergingSelectedBrush}" />
- </ObjectAnimationUsingKeyFrames>
- </Storyboard>
- </VisualState>
- <VisualState x:Name="NotMerging">
- </VisualState>
- </VisualStateGroup>
- </VisualStateManager.VisualStateGroups>
- <Grid.RowDefinitions>
- <RowDefinition Height="*" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="Auto" />
- </Grid.ColumnDefinitions>
- <c1:C1BrushBuilder x:Name="BackgroundBrush" Input="{TemplateBinding Background}" DesignBrush="{StaticResource DataGridColumnHeaderBrush}" DesignColor="{StaticResource BaseColor}" />
- <c1:C1BrushBuilder x:Name="MouseOverBrush" Input="{TemplateBinding MouseOverBrush}" DesignBrush="{StaticResource DataGridColumnHeaderOverBrush}" DesignColor="{StaticResource MouseOverColor}" />
- <c1:C1BrushBuilder x:Name="SelectedBackground" Input="{TemplateBinding SelectedBackground}" DesignBrush="{StaticResource DataGridColumnHeaderSelectedBackground}" DesignColor="{StaticResource SelectedColor}" />
- <c1:C1BrushBuilder x:Name="IconBrush" Input="{TemplateBinding Foreground}" DesignBrush="{StaticResource DataGridColumnHeaderIconBrush}" DesignColor="{StaticResource ForegroundColor}" />
- <c1:C1BrushBuilder x:Name="IconBorderBrush" Input="{TemplateBinding Foreground}" DesignBrush="{StaticResource DataGridColumnHeaderIconBorderBrush}" DesignColor="{StaticResource ForegroundColor}" />
- <Border x:Name="BackgroundElement" Background="Transparent" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.RowSpan="2" Grid.ColumnSpan="4" />
- <Border x:Name="SelectedElement" Background="{Binding ElementName=SelectedBackground, Path=Output}" BorderBrush="{TemplateBinding SelectedBackground}" BorderThickness="{TemplateBinding BorderThickness}" Grid.RowSpan="2" Grid.ColumnSpan="4" Visibility="Collapsed" />
- <Border x:Name="MouseOverElement" Background="{Binding ElementName=MouseOverBrush, Path=Output}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.RowSpan="2" Grid.ColumnSpan="4" Visibility="Collapsed" />
- <ToggleButton x:Name="Sort" Grid.RowSpan="2" Grid.ColumnSpan="2" Style="{StaticResource DataGridColumnHeaderSortTButtonStyle}" IsHitTestVisible="True" IsTabStop="False" Foreground="{TemplateBinding Foreground}" Margin="{StaticResource DataGridBorderThickness}" />
- <ContentPresenter x:Name="ContentPresenter" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="6,0,6,0" Visibility="Visible" />
- <c1:C1DropDown x:Name="Options" HorizontalAlignment="Right" Visibility="Collapsed" Template="{StaticResource DataGridColumnHeaderOptionsDDownStyle}" IsTabStop="False" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" Padding="0" Margin="{TemplateBinding BorderThickness}" AutoSizeMode="GrowHorizontally" MouseOverBrush="{TemplateBinding MouseOverBrush}" PressedBrush="{TemplateBinding PressedBrush}">
- <c1:C1DropDown.Header>
- <Grid>
- <Path x:Name="Filter" Data="M3.5,0.5 L4.5,0.5 L4.5,0.5 L7.5,0.5 L7.5,1.5 L7.5,1.5 L4.5,4.3 L4.5,7.5 L3.5,7.5 L3.5,4.3 L0.5,1.5 L0.5,0.5 L3.5,0.5 z" Fill="{Binding Output, ElementName=IconBrush}" Stroke="{Binding Output, ElementName=IconBorderBrush}" Style="{StaticResource DataGridColumnHeaderFilterIconStyle}" />
- <Polygon x:Name="OptionsArrow" Stretch="Uniform" Points="0,0 2,0 1,1" Fill="{Binding Output, ElementName=IconBrush}" Stroke="{Binding Output, ElementName=IconBorderBrush}" Style="{StaticResource DataGridColumnHeaderOptionsIconStyle}" />
- </Grid>
- </c1:C1DropDown.Header>
- </c1:C1DropDown>
- <Rectangle x:Name="Resize" Fill="White" Width="4" Grid.RowSpan="2" Grid.ColumnSpan="3" HorizontalAlignment="Right" Cursor="SizeWE" Opacity="0" Margin="0 0 -2 0" Visibility="Visible" />
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </c1:C1DataGrid.ColumnHeaderStyle>
复制代码
原来的DataGrid里数据多的时候,用虚拟化可以加快速度,我用c1DataGrid,没有这个属性了。
现在使用<c1:C1DataGrid Name="c1DataGrid1" ScrollMode="Deferred"/>即可
以后如有其他补充,随时修改 |