跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

浏览文件

ColorSelect.xaml

133 行 · 9.7 KB历史下载
1<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3 xmlns:local="clr-namespace:UI.Controls.Base" xmlns:button="clr-namespace:UI.Controls.Button" xmlns:converter="clr-namespace:UI.Controls.Converters">
4 <converter:HextoColorConverter x:Key="HextoColorConverter"/>
5
6 <Style TargetType="{x:Type local:ColorSelect}">
7 <Setter Property="SnapsToDevicePixels"
8 Value="true" />
9 <Setter Property="Background" Value="Transparent"/>
10
11 <Setter Property="Template">
12 <Setter.Value>
13 <ControlTemplate TargetType="{x:Type local:ColorSelect}">
14 <Border Background="{TemplateBinding Background}" SnapsToDevicePixels="True" BorderBrush="#f7f8fa" CornerRadius="5" BorderThickness="2" Width="38" Height="38">
15 <Border.InputBindings>
16 <MouseBinding Gesture="LeftClick" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ColorSelect}}, Path=ShowSelectCommand}"/>
17 </Border.InputBindings>
18 <Grid>
19 <Border CornerRadius="4" Width="28" Height="28" Background="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ColorSelect}}, Path=Color,Converter={StaticResource HextoColorConverter}}"/>
20 <Popup
21 x:Name="Popup"
22 Placement="Bottom"
23 IsOpen="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ColorSelect}}, Path=IsOpen,Mode=TwoWay}" AllowsTransparency="True" PopupAnimation="Slide"
24 >
25 <Border
26 x:Name="SelectContainer"
27 CornerRadius="10"
28 BorderBrush="{DynamicResource PopupBorderBrush}"
29 BorderThickness="1"
30 Background="{DynamicResource PopupBackgroundBrush}" Padding="10" Width="275" MaxHeight="300" Margin="10">
31 <Border.Effect>
32 <DropShadowEffect BlurRadius="6" ShadowDepth="2" Direction="315" Color="Gray" Opacity=".1"/>
33 </Border.Effect>
34 <Grid>
35 <Grid.RowDefinitions>
36 <RowDefinition Height="auto"/>
37 <RowDefinition Height="*"/>
38 <RowDefinition Height="auto"/>
39 </Grid.RowDefinitions>
40
41 <TextBlock Text="选择颜色" VerticalAlignment="Center" HorizontalAlignment="Left"/>
42
43 <ScrollViewer Grid.Row="1">
44 <ListView Grid.Row="1" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ColorSelect}}, Path=Colors}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ColorSelect}}, Path=Color,Mode=TwoWay}" Margin="0,10,0,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
45 <!--<i:Interaction.Triggers>
46 <i:EventTrigger EventName="MouseLeftButtonUp">
47 <i:InvokeCommandAction Command="{Binding GotoDetailCommand}"
48 CommandParameter="{Binding SelectedItem}" />
49 </i:EventTrigger>
50 </i:Interaction.Triggers>-->
51 <ListBox.Resources>
52 <Style TargetType="{x:Type ListView}">
53 <Setter Property="OverridesDefaultStyle" Value="True"/>
54
55 <Setter Property="Template">
56 <Setter.Value>
57 <ControlTemplate TargetType="{x:Type ListView}">
58 <Border>
59 <ItemsPresenter />
60 </Border>
61 </ControlTemplate>
62 </Setter.Value>
63 </Setter>
64 </Style>
65 <Style TargetType="{x:Type ListViewItem}">
66 <Setter Property="OverridesDefaultStyle" Value="True"/>
67 <Setter Property="Foreground" Value="#1a1a1a"/>
68
69 <Setter Property="Template">
70 <Setter.Value>
71 <ControlTemplate TargetType="{x:Type ListViewItem}">
72 <Border BorderBrush="Transparent" BorderThickness="2" x:Name="Border" Background="White" Margin="0,0,0,0" Padding="0" Width="35" Height="35" CornerRadius="5">
73 <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
74 </Border>
75 <ControlTemplate.Triggers>
76
77 <Trigger Property="IsMouseOver" Value="True">
78 <Setter TargetName="Border" Property="Background" Value="#FFE8E6FF"/>
79 <!--<Setter TargetName="Border" Property="BorderBrush" Value="#2b20d9"/>-->
80
81 </Trigger>
82 <Trigger Property="IsSelected" Value="True">
83 <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ThemeBrush}"/>
84 <Setter Property="Foreground" Value="White"/>
85
86 <!--<Setter TargetName="Border" Property="BorderBrush" Value="#2b20d9"/>-->
87
88 </Trigger>
89 </ControlTemplate.Triggers>
90 </ControlTemplate>
91 </Setter.Value>
92 </Setter>
93
94 </Style>
95 </ListBox.Resources>
96 <ListBox.ItemsPanel>
97 <ItemsPanelTemplate>
98 <WrapPanel/>
99 </ItemsPanelTemplate>
100 </ListBox.ItemsPanel>
101 <ListView.ItemTemplate>
102 <DataTemplate>
103
104 <WrapPanel Orientation="Horizontal">
105
106 <!--<local:Img URL="{Binding}" Width="25" Height="25"/>-->
107 <Border Width="25" CornerRadius="4" Height="25" Background="{Binding .,Converter={StaticResource HextoColorConverter}}">
108 </Border>
109
110 </WrapPanel>
111
112 </DataTemplate>
113 </ListView.ItemTemplate>
114 </ListView>
115 </ScrollViewer>
116 <button:Button Grid.Row="2" HorizontalAlignment="Right" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ColorSelect}}, Path=ColorSelectCommand}" Content="自定义颜色" Width="120"/>
117 </Grid>
118 </Border>
119
120 </Popup>
121 </Grid>
122 </Border>
123 <ControlTemplate.Triggers>
124
125 <Trigger Property="IsMouseOver" Value="True">
126 <Setter Property="Background" Value="{DynamicResource HoverBackgroundBrush}"/>
127 </Trigger>
128 </ControlTemplate.Triggers>
129 </ControlTemplate>
130 </Setter.Value>
131 </Setter>
132 </Style>
133</ResourceDictionary>