增加
This commit is contained in:
1 parent
993a91a545
commit
f772c35ede
27 files changed
+2585
-440
No files matched your search
+12
-1
@@ -4,5 +4,16 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Main.Test"
|
||||
xmlns:tf="Trade.Framework">
|
||||
<Application.Resources />
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Basic.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
|
||||
<ResourceDictionary Source="Dictionary1.xaml" />
|
||||
<ResourceDictionary Source="Dictionary2.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</tf:FrameworkApplication>
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Main.Test;
|
||||
|
||||
public class DataGridHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetNoDataTips(DependencyObject obj)
|
||||
{
|
||||
return (string)obj.GetValue(NoDataTipsProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetNoDataTips(DependencyObject obj, string value)
|
||||
{
|
||||
obj.SetValue(NoDataTipsProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty NoDataTipsProperty =
|
||||
DependencyProperty.RegisterAttached("NoDataTips", typeof(string), typeof(DataGridHelper),new PropertyMetadata("无数据"));
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool GetIsActive(DependencyObject obj)
|
||||
{
|
||||
return (bool)obj.GetValue(IsActiveProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetIsActive(DependencyObject obj, bool value)
|
||||
{
|
||||
obj.SetValue(IsActiveProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsActiveProperty =
|
||||
DependencyProperty.RegisterAttached("IsActive", typeof(bool), typeof(DataGridHelper));
|
||||
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ext="clr-namespace:Main.Test"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
<!--<FontFamily x:Key="FontFamily">Microsoft YaHei</FontFamily>
|
||||
-->
|
||||
<!-- 默认字体大小 -->
|
||||
<!--
|
||||
<sys:Double x:Key="DefaultFontSize">14</sys:Double>-->
|
||||
|
||||
|
||||
<Style x:Key="DefaultCellHeaderStyle" TargetType="DataGridColumnHeader">
|
||||
<Setter Property="Height" Value="{Binding ColumnHeaderHeight, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
|
||||
<Setter Property="Background" Value="#eeeeee" />
|
||||
<Setter Property="BorderThickness" Value="1,0,1,1" />
|
||||
<Setter Property="Margin" Value="-1,0,0,0" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=HorizontalContentAlignment}" />
|
||||
<Setter Property="Padding" Value="8,0" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
|
||||
<Setter Property="BorderBrush" Value="{Binding HorizontalGridLinesBrush, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="DataGridColumnHeader">
|
||||
<Grid>
|
||||
<Border
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
||||
<ContentPresenter
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
<Grid
|
||||
x:Name="SortArrowGrid"
|
||||
Grid.Column="1"
|
||||
Width="7"
|
||||
Height="15"
|
||||
Margin="10,0,5,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Hidden">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Path
|
||||
x:Name="SortArrowUp"
|
||||
Margin="0,0,0,2"
|
||||
Data="M500 365.76l-244.78 279.7a16 16 0 0 0 12 26.54h489.52a16 16 0 0 0 12-26.54L524 365.76a16 16 0 0 0-24 0z"
|
||||
Fill="#D2D2D2"
|
||||
Stretch="Fill" />
|
||||
<Path
|
||||
x:Name="SortArrowDown"
|
||||
Grid.Row="1"
|
||||
Margin="0,2,0,0"
|
||||
Data="M524 658.24l244.74-279.7a16 16 0 0 0-12-26.54H267.26a16 16 0 0 0-12 26.54L500 658.24a16 16 0 0 0 24 0z"
|
||||
Fill="#D2D2D2"
|
||||
Stretch="Fill" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Thumb
|
||||
x:Name="PART_LeftHeaderGripper"
|
||||
HorizontalAlignment="Left"
|
||||
Cursor="SizeWE"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Opacity="0" />
|
||||
<Thumb
|
||||
x:Name="PART_RightHeaderGripper"
|
||||
HorizontalAlignment="Right"
|
||||
Cursor="SizeWE"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Opacity="0" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="SortDirection" Value="Ascending">
|
||||
<Setter TargetName="SortArrowGrid" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="SortArrowUp" Property="Fill" Value="#61646D" />
|
||||
<Setter TargetName="SortArrowDown" Property="Fill" Value="#D2D2D2" />
|
||||
</Trigger>
|
||||
<Trigger Property="SortDirection" Value="Descending">
|
||||
<Setter TargetName="SortArrowGrid" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="SortArrowUp" Property="Fill" Value="#D2D2D2" />
|
||||
<Setter TargetName="SortArrowDown" Property="Fill" Value="#61646D" />
|
||||
</Trigger>
|
||||
<Trigger Property="SortDirection" Value="{x:Null}">
|
||||
<Setter TargetName="SortArrowGrid" Property="Visibility" Value="Hidden" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding GridLinesVisibility, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Value="None">
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultCellStyle" TargetType="DataGridCell">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Padding" Value="8,0" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
|
||||
<!--<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType=DataGrid, Mode=FindAncestor}, Path=Foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />-->
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridCell}">
|
||||
<Grid>
|
||||
<Border
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<!-- 选中后颜色改变 -->
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultRowHeaderStyle" TargetType="{x:Type DataGridRowHeader}">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultRowStyle" TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="BorderThickness" Value="0,0,1,0" />
|
||||
<Setter Property="Background" Value="{x:Null}" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
|
||||
<Setter Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource AncestorType=DataGrid, Mode=FindAncestor}, Path=BorderBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="DataGridRow">
|
||||
<Grid>
|
||||
<Border
|
||||
x:Name="border"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" />
|
||||
<SelectiveScrollingGrid>
|
||||
<SelectiveScrollingGrid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</SelectiveScrollingGrid.ColumnDefinitions>
|
||||
<SelectiveScrollingGrid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</SelectiveScrollingGrid.RowDefinitions>
|
||||
<DataGridCellsPresenter
|
||||
Grid.Column="1"
|
||||
ItemsPanel="{TemplateBinding ItemsPanel}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
<DataGridDetailsPresenter
|
||||
x:Name="DetailsPresenter"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
|
||||
Visibility="{TemplateBinding DetailsVisibility}" />
|
||||
<DataGridRowHeader
|
||||
Grid.RowSpan="2"
|
||||
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
|
||||
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
|
||||
</SelectiveScrollingGrid>
|
||||
<Grid
|
||||
x:Name="fousIcon"
|
||||
IsHitTestVisible="False"
|
||||
Opacity="0">
|
||||
<Path
|
||||
Width="10"
|
||||
Height="10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Data="M0,0 L0,0 50,0 50,10 10,10 10,50 0,50 0,52 z"
|
||||
Fill="#4BB2FF"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Stretch="Fill">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform />
|
||||
<SkewTransform />
|
||||
<RotateTransform Angle="0" />
|
||||
<TranslateTransform />
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
<Path
|
||||
Width="10"
|
||||
Height="10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Data="M0,0 L0,0 50,0 50,10 10,10 10,50 0,50 0,52 z"
|
||||
Fill="#4BB2FF"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Stretch="Fill">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform />
|
||||
<SkewTransform />
|
||||
<RotateTransform Angle="90" />
|
||||
<TranslateTransform />
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
<Path
|
||||
Width="10"
|
||||
Height="10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Data="M0,0 L0,0 50,0 50,10 10,10 10,50 0,50 0,52 z"
|
||||
Fill="#4BB2FF"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Stretch="Fill">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform />
|
||||
<SkewTransform />
|
||||
<RotateTransform Angle="180" />
|
||||
<TranslateTransform />
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
<Path
|
||||
Width="10"
|
||||
Height="10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Bottom"
|
||||
Data="M0,0 L0,0 50,0 50,10 10,10 10,50 0,50 0,52 z"
|
||||
Fill="#4BB2FF"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Stretch="Fill">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform />
|
||||
<SkewTransform />
|
||||
<RotateTransform Angle="-90" />
|
||||
<TranslateTransform />
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter TargetName="fousIcon" Property="Opacity" Value="1" />
|
||||
<!-- 整行变色 -->
|
||||
<Setter TargetName="border" Property="Background" Value="#4BB2FF" />
|
||||
</Trigger>
|
||||
<Trigger Property="DetailsVisibility" Value="Visible">
|
||||
<Setter TargetName="DetailsPresenter" Property="Margin" Value="0,0,1,0" />
|
||||
</Trigger>
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style
|
||||
x:Key="DefaultNumberCellHeaderStyle"
|
||||
BasedOn="{StaticResource DefaultCellHeaderStyle}"
|
||||
TargetType="DataGridColumnHeader">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right" />
|
||||
</Style>
|
||||
|
||||
<Style
|
||||
x:Key="DefaultNumberCellStyle"
|
||||
BasedOn="{StaticResource DefaultCellStyle}"
|
||||
TargetType="DataGridCell">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultDataGridStyle" TargetType="DataGrid">
|
||||
<Setter Property="Background" Value="White" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="ColumnHeaderHeight" Value="36" />
|
||||
<Setter Property="MinRowHeight" Value="40" />
|
||||
<Setter Property="RowHeaderWidth" Value="0" />
|
||||
<Setter Property="CanUserAddRows" Value="False" />
|
||||
<Setter Property="AutoGenerateColumns" Value="False" />
|
||||
<Setter Property="CanUserSortColumns" Value="True" />
|
||||
<Setter Property="CanUserReorderColumns" Value="False" />
|
||||
<Setter Property="AreRowDetailsFrozen" Value="False" />
|
||||
<Setter Property="HeadersVisibility" Value="All" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Foreground" Value="#343A40" />
|
||||
<Setter Property="BorderBrush" Value="#D2D2D2" />
|
||||
<Setter Property="VerticalGridLinesBrush" Value="#D2D2D2" />
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="#D2D2D2" />
|
||||
<Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected" />
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
|
||||
<Setter Property="SelectionMode" Value="Single" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
|
||||
<Setter Property="RowHeaderStyle" Value="{DynamicResource DefaultRowHeaderStyle}" />
|
||||
<Setter Property="RowStyle" Value="{DynamicResource DefaultRowStyle}" />
|
||||
<Setter Property="ColumnHeaderStyle" Value="{DynamicResource DefaultCellHeaderStyle}" />
|
||||
<Setter Property="CellStyle" Value="{DynamicResource DefaultCellStyle}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGrid}">
|
||||
<Border
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
SnapsToDevicePixels="True">
|
||||
<ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
|
||||
<ScrollViewer.Template>
|
||||
<ControlTemplate TargetType="{x:Type ScrollViewer}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<DataGridColumnHeadersPresenter
|
||||
x:Name="PART_ColumnHeadersPresenter"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="1">
|
||||
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" />
|
||||
<Grid
|
||||
x:Name="NoDataTipsGrid"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
IsHitTestVisible="False"
|
||||
Visibility="Collapsed">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Path
|
||||
Width="100"
|
||||
Height="60"
|
||||
Data="M156.662278 699.758173h21.097186A10.444152 10.444152 0 0 1 187.994733 710.202325c0 5.765172-4.490985 10.444152-10.235269 10.444152H156.662278v21.097186A10.444152 10.444152 0 0 1 146.218126 751.978932a10.277045 10.277045 0 0 1-10.444152-10.235269V720.646477H114.676787A10.444152 10.444152 0 0 1 104.441518 710.202325c0-5.765172 4.490985-10.444152 10.235269-10.444152H135.773974v-21.097187A10.444152 10.444152 0 0 1 146.218126 668.425717c5.765172 0 10.444152 4.490985 10.444152 10.235269v21.097187z m1378.628042-83.553215v-21.097186A10.277045 10.277045 0 0 0 1524.846168 584.872503a10.444152 10.444152 0 0 0-10.444152 10.235269v21.097186h-21.097186a10.277045 10.277045 0 0 0-10.235269 10.444152c0 5.598065 4.595427 10.444152 10.235269 10.444152h21.097186v21.097187c0 5.744284 4.67898 10.235269 10.444152 10.235268a10.444152 10.444152 0 0 0 10.444152-10.235268V637.093262h21.097187c5.744284 0 10.235269-4.67898 10.235268-10.444152a10.444152 10.444152 0 0 0-10.235268-10.444152H1535.29032zM776.460024 960.861969H250.596979A20.80475 20.80475 0 0 1 229.77134 939.973665c0-11.530344 9.462402-20.888304 20.825639-20.888303h94.728457A83.010119 83.010119 0 0 1 334.212859 877.413196v-605.96969A83.49055 83.49055 0 0 1 417.849627 187.994733H480.430984V167.001988A83.49055 83.49055 0 0 1 564.067752 83.553215h501.152182A83.448773 83.448773 0 0 1 1148.856702 167.001988v605.969689c0 15.185797-4.052331 29.410732-11.133466 41.672166h115.554096c11.551232 0 20.909192 9.274407 20.909192 20.888304 0 11.530344-9.295295 20.888304-20.888304 20.888304H1002.638576v20.992745c0 15.185797-4.052331 29.410732-11.133466 41.672166h11.196131c11.488567 0 20.825639 9.274407 20.825639 20.888303 0 11.530344-9.462402 20.888304-20.825639 20.888304h-109.893365c9.545955 16.000441 7.478013 36.972297-6.41271 50.863019a41.672166 41.672166 0 0 1-59.072122 0L776.460024 960.861969z m76.367638-41.776607h66.424806c22.977134 0 41.609501-18.59059 41.609501-41.881049V270.461756c0-22.559368-18.047494-40.690416-40.314426-40.690416H416.303892c-22.266932 0-40.314426 18.214601-40.314426 40.690416v606.742557c0 23.123352 18.799473 41.881049 41.588613 41.881049h317.084449l-10.736588-10.757477a41.693054 41.693054 0 0 1-10.861918-40.377091l-19.718558-19.739447A146.259902 146.259902 0 0 1 502.363703 627.693525a146.218126 146.218126 0 0 1 220.517822 190.981761l19.739447 19.739447a41.630389 41.630389 0 0 1 40.377091 10.841029L852.827662 919.085362zM1002.638576 814.643843h62.852906A41.797496 41.797496 0 0 0 1107.080095 772.867236V167.106429c0-23.14424-18.632367-41.776607-41.588613-41.776607H563.775316A41.797496 41.797496 0 0 0 522.207592 167.106429v20.888304h396.794216A83.448773 83.448773 0 0 1 1002.638576 271.443506V814.643843zM266.325872 46.998683h31.123572c8.773088 0 15.875111 6.955805 15.875111 15.666228 0 8.647758-7.102023 15.666228-15.875111 15.666228h-31.123572v31.123572c0 8.773088-6.955805 15.875111-15.666228 15.875111a15.770669 15.770669 0 0 1-15.666228-15.875111V78.331139H203.869844A15.728893 15.728893 0 0 1 187.994733 62.664911c0-8.647758 7.102023-15.666228 15.875111-15.666228h31.123572V15.875111c0-8.773088 6.955805-15.875111 15.666228-15.875111 8.647758 0 15.666228 7.102023 15.666228 15.875111v31.123572zM20.888304 939.973665c0-11.530344 9.462402-20.888304 20.825638-20.888303h125.455152c11.488567 0 20.825639 9.274407 20.825639 20.888303 0 11.530344-9.462402 20.888304-20.825639 20.888304H41.713942A20.80475 20.80475 0 0 1 20.888304 939.973665z m658.733544-135.021995a104.441518 104.441518 0 1 0-147.722083-147.722083 104.441518 104.441518 0 0 0 147.722083 147.722083zM459.542681 313.324555a20.888304 20.888304 0 0 1 20.867415-20.888304H710.202325a20.888304 20.888304 0 1 1 0 41.776608H480.430984A20.825639 20.825639 0 0 1 459.542681 313.324555z m0 104.441518c0-11.530344 9.295295-20.888304 20.742085-20.888303h334.505295c11.44679 0 20.742086 9.274407 20.742086 20.888303 0 11.530344-9.295295 20.888304-20.742086 20.888304H480.284766A20.762974 20.762974 0 0 1 459.542681 417.766073z m0 104.441519c0-11.530344 9.316183-20.888304 20.846527-20.888304h146.301679c11.509455 0 20.846527 9.274407 20.846527 20.888304 0 11.530344-9.316183 20.888304-20.846527 20.888303h-146.301679A20.80475 20.80475 0 0 1 459.542681 522.207592zM62.664911 396.87777a62.664911 62.664911 0 1 1 0-125.329822 62.664911 62.664911 0 0 1 0 125.329822z m0-31.332456a31.332456 31.332456 0 1 0 0-62.664911 31.332456 31.332456 0 0 0 0 62.664911zM1357.739739 271.547948a62.664911 62.664911 0 1 1 0-125.329822 62.664911 62.664911 0 0 1 0 125.329822z m0-31.332456a31.332456 31.332456 0 1 0 0-62.664911 31.332456 31.332456 0 0 0 0 62.664911z"
|
||||
Fill="LightGray"
|
||||
Stretch="Fill" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Margin="10"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Bottom"
|
||||
FontSize="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=FontSize, Mode=OneWay}"
|
||||
Foreground="LightGray"
|
||||
Text="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=(ext:DataGridHelper.NoDataTips), Mode=OneWay}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ScrollBar
|
||||
x:Name="PART_VerticalScrollBar"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Maximum="{TemplateBinding ScrollableHeight}"
|
||||
Orientation="Vertical"
|
||||
Style="{DynamicResource LeadScrollBarStyle}"
|
||||
ViewportSize="{TemplateBinding ViewportHeight}"
|
||||
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
|
||||
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<Grid Grid.Row="2" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ScrollBar
|
||||
x:Name="PART_HorizontalScrollBar"
|
||||
Grid.Column="1"
|
||||
Maximum="{TemplateBinding ScrollableWidth}"
|
||||
Orientation="Horizontal"
|
||||
Style="{DynamicResource LeadScrollBarStyle}"
|
||||
ViewportSize="{TemplateBinding ViewportWidth}"
|
||||
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
|
||||
Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=(ext:DataGridHelper.IsActive)}" Value="false" />
|
||||
<Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=HasItems}" Value="false" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter TargetName="NoDataTipsGrid" Property="Visibility" Value="Visible" />
|
||||
</MultiDataTrigger>
|
||||
<!--<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=(ext:DataGridHelper.NoDataTips)}" Value="{x:Null}">
|
||||
<Setter TargetName="NoDataTipsGrid" Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=(ext:DataGridHelper.NoDataTips)}" Value="">
|
||||
<Setter TargetName="NoDataTipsGrid" Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>-->
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</ScrollViewer.Template>
|
||||
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsGrouping" Value="true" />
|
||||
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,428 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||
|
||||
<!-- DataGrid -->
|
||||
<SolidColorBrush x:Key="ColumnHeaderBackgroundBrush" Color="#FAFAFA" />
|
||||
<SolidColorBrush x:Key="ColumnHeaderBorderBrush" Color="#FAFAFA" />
|
||||
|
||||
<Style
|
||||
x:Key="DataGridColumnHeader.MarginSmall"
|
||||
BasedOn="{StaticResource DataGridColumnHeaderStyle}"
|
||||
TargetType="{x:Type DataGridColumnHeader}">
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
|
||||
<Setter Property="Padding" Value="6,0" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="BorderThickness" Value="0,0,1,1" />
|
||||
<Setter Property="BorderBrush" Value="{Binding VerticalGridLinesBrush, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="DataGridColumnHeader">
|
||||
<hc:SimplePanel SnapsToDevicePixels="True">
|
||||
<Border
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{StaticResource ColumnHeaderBackgroundBrush}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
SnapsToDevicePixels="True"
|
||||
UseLayoutRounding="True">
|
||||
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter
|
||||
VerticalAlignment="Center"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
<ToggleButton
|
||||
x:Name="ToggleButtonSortDirection"
|
||||
Grid.Column="1"
|
||||
Width="20"
|
||||
Padding="4,0"
|
||||
VerticalAlignment="Center"
|
||||
hc:IconSwitchElement.Geometry="{StaticResource DownGeometry}"
|
||||
hc:IconSwitchElement.GeometrySelected="{StaticResource UpGeometry}"
|
||||
Foreground="{DynamicResource TextIconBrush}"
|
||||
IsEnabled="False"
|
||||
Opacity="1"
|
||||
Style="{StaticResource ToggleButtonIconTransparent}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<Thumb
|
||||
x:Name="PART_LeftHeaderGripper"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{StaticResource ColumnHeaderGripperStyle}" />
|
||||
<Thumb
|
||||
x:Name="PART_RightHeaderGripper"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{StaticResource ColumnHeaderGripperStyle}" />
|
||||
</hc:SimplePanel>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="SortDirection" Value="{x:Null}">
|
||||
<Setter TargetName="ToggleButtonSortDirection" Property="Visibility" Value="Collapsed" />
|
||||
</Trigger>
|
||||
<Trigger Property="SortDirection" Value="Ascending">
|
||||
<Setter TargetName="ToggleButtonSortDirection" Property="IsChecked" Value="True" />
|
||||
</Trigger>
|
||||
<Trigger Property="SortDirection" Value="Descending">
|
||||
<Setter TargetName="ToggleButtonSortDirection" Property="IsChecked" Value="False" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--
|
||||
行样式:不再手工画顶部边框,横线统一交给 DataGrid.HorizontalGridLinesBrush 处理,
|
||||
避免行/单元格分层画线导致的交界处错位、断线问题。
|
||||
-->
|
||||
<Style
|
||||
x:Key="DataGridRowStyle.MarginSmall"
|
||||
BasedOn="{StaticResource DataGridRowStyle}"
|
||||
TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
</Style>
|
||||
|
||||
<Style
|
||||
x:Key="DataGridRowStyle.Rightangle"
|
||||
BasedOn="{StaticResource DataGridRowStyle.MarginSmall}"
|
||||
TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridRow}">
|
||||
<SelectiveScrollingGrid>
|
||||
<SelectiveScrollingGrid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</SelectiveScrollingGrid.ColumnDefinitions>
|
||||
<SelectiveScrollingGrid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</SelectiveScrollingGrid.RowDefinitions>
|
||||
<Border
|
||||
Name="DGR_Border"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="0"
|
||||
SelectiveScrollingGrid.ColumnSpan="2"
|
||||
SnapsToDevicePixels="True" />
|
||||
<DataGridCellsPresenter
|
||||
MinHeight="{TemplateBinding MinHeight}"
|
||||
VerticalContentAlignment="Center"
|
||||
ItemsPanel="{TemplateBinding ItemsPanel}"
|
||||
SelectiveScrollingGrid.Column="1"
|
||||
SelectiveScrollingGrid.Row="0"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
<DataGridDetailsPresenter
|
||||
Margin="0,6"
|
||||
SelectiveScrollingGrid.Column="1"
|
||||
SelectiveScrollingGrid.Row="1"
|
||||
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
Visibility="{TemplateBinding DetailsVisibility}" />
|
||||
<DataGridRowHeader
|
||||
SelectiveScrollingGrid.Column="0"
|
||||
SelectiveScrollingGrid.Row="0"
|
||||
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
|
||||
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}" />
|
||||
</SelectiveScrollingGrid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--
|
||||
单元格样式:去掉自绘右边框,竖线统一交给 DataGrid.VerticalGridLinesBrush 处理。
|
||||
-->
|
||||
<Style
|
||||
x:Key="DataGridCellStyle.Rightangle"
|
||||
BasedOn="{StaticResource DataGridCellStyle}"
|
||||
TargetType="{x:Type DataGridCell}">
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
</Style>
|
||||
<!-- {x:Type DataGrid} -->
|
||||
|
||||
<Style
|
||||
x:Key="DataGrid.Custom"
|
||||
BasedOn="{StaticResource DataGridBaseStyle}"
|
||||
TargetType="{x:Type DataGrid}">
|
||||
<Setter Property="IsReadOnly" Value="True" />
|
||||
<Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle.Rightangle}" />
|
||||
<Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle.Rightangle}" />
|
||||
<Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGridColumnHeader.MarginSmall}" />
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
|
||||
<!-- 统一由 DataGrid 渲染网格线,避免行/列各自画线导致的错位 -->
|
||||
<Setter Property="GridLinesVisibility" Value="All" />
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="{StaticResource BorderBrush}" />
|
||||
<Setter Property="VerticalGridLinesBrush" Value="{StaticResource BorderBrush}" />
|
||||
<Setter Property="RowHeight" Value="26" />
|
||||
<Setter Property="ColumnHeaderHeight" Value="28" />
|
||||
<!--
|
||||
表头边框(Border 绘制)和内容区网格线(DataGrid 内部 Pen 绘制)走的是两套渲染路径,
|
||||
统一开启像素对齐,避免非整数 DPI 下两者出现 1px 错位
|
||||
-->
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="UseLayoutRounding" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="DataGrid">
|
||||
<ControlTemplate.Resources>
|
||||
<!--<Storyboard x:Key="StoryboardMouseEnter">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_VerticalScrollBar" Storyboard.TargetProperty="Opacity">
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value=".8" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_HorizontalScrollBar" Storyboard.TargetProperty="Opacity">
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value=".8" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="StoryboardMouseLeave">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_VerticalScrollBar" Storyboard.TargetProperty="Opacity">
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_HorizontalScrollBar" Storyboard.TargetProperty="Opacity">
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>-->
|
||||
</ControlTemplate.Resources>
|
||||
<Border
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SnapsToDevicePixels="True">
|
||||
<ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
|
||||
<ScrollViewer.Template>
|
||||
<ControlTemplate TargetType="ScrollViewer">
|
||||
<Border Margin="0,0,-1,0" ClipToBounds="True">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Background="{StaticResource ColumnHeaderBackgroundBrush}">
|
||||
<Button
|
||||
Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType=DataGrid}, Converter={StaticResource DoubleMinConverter}}"
|
||||
Height="auto"
|
||||
MaxHeight="30"
|
||||
hc:IconElement.Geometry="{StaticResource AllGeometry}"
|
||||
Command="{x:Static DataGrid.SelectAllCommand}"
|
||||
Foreground="{DynamicResource PrimaryBrush}"
|
||||
IsEnabled="False"
|
||||
Style="{StaticResource ButtonIcon}"
|
||||
Visibility="Hidden">
|
||||
<!--<Button.Visibility>
|
||||
<MultiBinding Converter="{StaticResource DataGridSelectAllButtonVisibilityConverter}">
|
||||
<Binding Path="HeadersVisibility" RelativeSource="{RelativeSource AncestorType=DataGrid}" />
|
||||
<Binding Path="(hc:DataGridAttach.ShowSelectAllButton)" RelativeSource="{RelativeSource AncestorType=DataGrid}" />
|
||||
</MultiBinding>
|
||||
</Button.Visibility>-->
|
||||
</Button>
|
||||
</Grid>
|
||||
<DataGridColumnHeadersPresenter
|
||||
x:Name="PART_ColumnHeadersPresenter"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}" />
|
||||
<ScrollContentPresenter
|
||||
x:Name="PART_ScrollContentPresenter"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
CanContentScroll="{TemplateBinding CanContentScroll}" />
|
||||
<hc:ToggleBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
IsChecked="{Binding HasItems, RelativeSource={RelativeSource AncestorType=DataGrid}, Mode=OneWay}">
|
||||
<hc:ToggleBlock.UnCheckedContent>
|
||||
<hc:Empty
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" />
|
||||
</hc:ToggleBlock.UnCheckedContent>
|
||||
</hc:ToggleBlock>
|
||||
<ScrollBar
|
||||
x:Name="PART_VerticalScrollBar"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="3"
|
||||
Grid.Column="2"
|
||||
Maximum="{TemplateBinding ScrollableHeight}"
|
||||
Orientation="Vertical"
|
||||
Style="{StaticResource BaseStyle}"
|
||||
ViewportSize="{TemplateBinding ViewportHeight}"
|
||||
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
|
||||
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<ScrollBar
|
||||
x:Name="PART_HorizontalScrollBar"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Bottom"
|
||||
Maximum="{TemplateBinding ScrollableWidth}"
|
||||
Orientation="Horizontal"
|
||||
Style="{StaticResource BaseStyle}"
|
||||
ViewportSize="{TemplateBinding ViewportWidth}"
|
||||
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
|
||||
Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<!--<ControlTemplate.Triggers>
|
||||
<EventTrigger RoutedEvent="MouseEnter">
|
||||
<BeginStoryboard Storyboard="{StaticResource StoryboardMouseEnter}" />
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="MouseLeave">
|
||||
<BeginStoryboard Storyboard="{StaticResource StoryboardMouseLeave}" />
|
||||
</EventTrigger>
|
||||
</ControlTemplate.Triggers>-->
|
||||
</ControlTemplate>
|
||||
</ScrollViewer.Template>
|
||||
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
|
||||
<Style x:Key="DataGridLinkColumn" TargetType="Hyperlink">
|
||||
<Setter Property="Foreground" Value="{StaticResource PrimaryBrush}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Path=IsSelected}" Value="True">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextIconBrush}" />
|
||||
</DataTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="Selector.IsSelectionActive" Value="false" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}" />
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
Small 行样式:沿用 Rightangle 的模板(不再自画顶部边框),
|
||||
网格线线统一交由 DataGrid.Custom.Small 的 GridLinesVisibility 处理。
|
||||
-->
|
||||
<Style
|
||||
x:Key="DataGridRowStyle.Rightangle.Small"
|
||||
BasedOn="{StaticResource DataGridRowStyle.Rightangle}"
|
||||
TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
<Setter Property="Padding" Value="0,0" />
|
||||
</Style>
|
||||
|
||||
<Style
|
||||
x:Key="DataGridCellStyle.Custom.Small"
|
||||
BasedOn="{StaticResource DataGridCellStyle}"
|
||||
TargetType="DataGridCell">
|
||||
<Setter Property="Padding" Value="6,3" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="TextBlock.TextAlignment" Value="Right" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridCell}">
|
||||
<Border Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||
<ContentPresenter
|
||||
Margin="{TemplateBinding Padding}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<MultiDataTrigger.Setters>
|
||||
<Setter Property="Background" Value="#cde6f7" />
|
||||
</MultiDataTrigger.Setters>
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="DataGridColumnHeaderStyle.Custom"
|
||||
BasedOn="{StaticResource DataGridColumnHeader.MarginSmall}"
|
||||
TargetType="DataGridColumnHeader">
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
<Setter Property="Padding" Value="6,4" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="DataGridRowHeaderStyle.Custom"
|
||||
BasedOn="{StaticResource DataGridRowHeaderStyle}"
|
||||
TargetType="DataGridRowHeader">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridRowHeader}">
|
||||
<hc:SimplePanel>
|
||||
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<ContentPresenter
|
||||
VerticalAlignment="Center"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Thumb
|
||||
Name="PART_TopHeaderGripper"
|
||||
VerticalAlignment="Top"
|
||||
Style="{StaticResource RowHeaderGripperStyle}" />
|
||||
<Thumb
|
||||
Name="PART_BottomHeaderGripper"
|
||||
VerticalAlignment="Bottom"
|
||||
Style="{StaticResource RowHeaderGripperStyle}" />
|
||||
</hc:SimplePanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<!-- {x:Type DataGrid} -->
|
||||
<Style
|
||||
x:Key="DataGrid.Custom.Small"
|
||||
BasedOn="{StaticResource DataGrid.Custom}"
|
||||
TargetType="{x:Type DataGrid}">
|
||||
<!-- 原来是 18,行内容会被挤压;24 能容纳默认字号并留出上下呼吸空间 -->
|
||||
<Setter Property="RowHeight" Value="24" />
|
||||
<Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle.Rightangle.Small}" />
|
||||
<Setter Property="Padding" Value="1" />
|
||||
<Setter Property="RowHeaderStyle" Value="{StaticResource DataGridRowHeaderStyle.Custom}" />
|
||||
<Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle.Custom.Small}" />
|
||||
<Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGridColumnHeaderStyle.Custom}" />
|
||||
<Setter Property="ColumnHeaderHeight" Value="24" />
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- DataGridEnd -->
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -8,6 +8,10 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bogus" Version="35.6.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Source\Trade.Framework\Trade.Framework.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<UserControl
|
||||
x:Class="Main.Test.MainHeaderImageContent"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Main.Test"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Height="200"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Grid />
|
||||
</UserControl>
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Main.Test
|
||||
{
|
||||
/// <summary>
|
||||
/// MainHeaderImageContent.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainHeaderImageContent : UserControl
|
||||
{
|
||||
public MainHeaderImageContent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void IndicatorItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
TryDragMove();
|
||||
}
|
||||
|
||||
private void TimeItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
TryDragMove();
|
||||
}
|
||||
|
||||
private void TryDragMove()
|
||||
{
|
||||
Window window = Application.Current?.MainWindow;
|
||||
if (window is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
//if (window.WindowState == WindowState.Maximized)
|
||||
//{
|
||||
// window.WindowState = WindowState.Normal;
|
||||
//}
|
||||
window.DragMove();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,57 @@
|
||||
<Window
|
||||
<tf:WindowBase
|
||||
x:Class="Main.Test.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Main.Test"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:views="clr-namespace:Main.Test.Views"
|
||||
Title="MainWindow"
|
||||
xmlns:tf="Trade.Framework"
|
||||
xmlns:views="clr-namespace:Main.Test.Views"
|
||||
xmlns:vm="clr-namespace:Main.Test.ViewModels"
|
||||
Title="MainWindow"
|
||||
Width="800"
|
||||
Height="450"
|
||||
DataContext="{tf:DISource Type=vm:MainViewModel}"
|
||||
NonClientAreaContent=""
|
||||
NonClientAreaHeight="200"
|
||||
ResizeMode="CanResizeWithGrip"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<views:HeaderView />
|
||||
|
||||
<Grid Margin="0,0,0,0">
|
||||
<DataGrid
|
||||
Height="Auto"
|
||||
d:ItemsSource="{d:SampleData ItemCount=10}"
|
||||
ItemsSource="{Binding Data}"
|
||||
Style="{StaticResource DefaultDataGridStyle}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="1*"
|
||||
MinWidth="100"
|
||||
Binding="{Binding Code, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Header="编码"
|
||||
IsReadOnly="True" />
|
||||
<DataGridTextColumn
|
||||
Width="1*"
|
||||
MinWidth="100"
|
||||
Binding="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Header="名称"
|
||||
IsReadOnly="True" />
|
||||
<DataGridTextColumn
|
||||
Width="1*"
|
||||
MinWidth="100"
|
||||
Binding="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Header="值"
|
||||
IsReadOnly="True" />
|
||||
<DataGridTextColumn
|
||||
Width="1*"
|
||||
MinWidth="100"
|
||||
Binding="{Binding Qty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
CellStyle="{DynamicResource DefaultNumberCellStyle}"
|
||||
Header="数字"
|
||||
HeaderStyle="{DynamicResource DefaultNumberCellHeaderStyle}"
|
||||
IsReadOnly="True" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Window>
|
||||
</tf:WindowBase>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using Bogus;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
@@ -8,15 +9,27 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Trade.Framework.Controls;
|
||||
|
||||
namespace Main.Test;
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
public partial class MainWindow : WindowBase
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
var mainHeaderImageContent = new MainHeaderImageContent();
|
||||
NonClientAreaHeight = mainHeaderImageContent.Height;
|
||||
NonClientAreaContent = mainHeaderImageContent;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemInfo
|
||||
{
|
||||
public int Code { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public int Qty { get; set; }
|
||||
}
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Input;
|
||||
|
||||
namespace Main.Test.ViewModels;
|
||||
|
||||
internal class HeaderViewModel
|
||||
internal partial class HeaderViewModel
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MAX.Core.Logger;
|
||||
using Bogus;
|
||||
using MAX.Core.Logger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -11,10 +12,27 @@ namespace Main.Test.ViewModels;
|
||||
internal class MainViewModel
|
||||
{
|
||||
private readonly ILoggerFacade _logger;
|
||||
public List<ItemInfo> Data { get; set; }
|
||||
|
||||
public MainViewModel(ILoggerFacade logger, UserManager userManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_logger.Info("123123");
|
||||
|
||||
|
||||
|
||||
// 创建 Faker 并配置规则
|
||||
var itemFaker = new Faker<ItemInfo>()
|
||||
.RuleFor(x => x.Code, f => f.Random.Int(1000, 9999)) // 4位随机编码
|
||||
.RuleFor(x => x.Name, f => f.Commerce.ProductName()) // 商品名称
|
||||
.RuleFor(x => x.Value, f => f.Commerce.Price().ToString()) // 商品价格
|
||||
.RuleFor(x => x.Qty, f => f.Random.Int(1, 100)); // 1-100的随机数量
|
||||
|
||||
// 生成单个对象
|
||||
var singleItem = itemFaker.Generate();
|
||||
|
||||
// 生成100个对象
|
||||
Data = itemFaker.Generate(100);
|
||||
//Data.Clear();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user