168 lines
7.2 KiB
XML
168 lines
7.2 KiB
XML
<UserControl
|
|
x:Class="MelskinTest.ColorPaletteControl"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:local="clr-namespace:MelskinTest"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
<UserControl.Resources>
|
|
<DataTemplate x:Key="ColorItemTemplate">
|
|
<Border
|
|
Background="{Binding Value}"
|
|
BorderBrush="#CCC"
|
|
BorderThickness="1"
|
|
CornerRadius="8"
|
|
Margin="4">
|
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
|
<Ellipse
|
|
Fill="{Binding Value}"
|
|
Height="32"
|
|
Margin="8,0"
|
|
Stroke="#888"
|
|
StrokeThickness="1"
|
|
Width="32" />
|
|
<StackPanel>
|
|
<TextBlock
|
|
FontWeight="SemiBold"
|
|
Text="{Binding Key}"
|
|
TextWrapping="WrapWithOverflow" />
|
|
<TextBlock FontSize="12" Text="{Binding Value}" />
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</Border>
|
|
</DataTemplate>
|
|
<DataTemplate x:Key="BrushItemTemplate">
|
|
<Border
|
|
Background="{Binding Value}"
|
|
BorderBrush="#CCC"
|
|
BorderThickness="1"
|
|
CornerRadius="8"
|
|
Margin="4">
|
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
|
<Ellipse
|
|
Fill="{Binding Value}"
|
|
Height="32"
|
|
Margin="8,0"
|
|
Stroke="#888"
|
|
StrokeThickness="1"
|
|
Width="32" />
|
|
<StackPanel>
|
|
<TextBlock FontWeight="SemiBold" Text="{Binding Key}" />
|
|
<TextBlock FontSize="12" Text="{Binding Value.Color}" />
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</Border>
|
|
</DataTemplate>
|
|
<!-- 新增颜色分组 -->
|
|
<CollectionViewSource Source="{Binding ColorResources}" x:Key="ColorGroups">
|
|
<CollectionViewSource.GroupDescriptions>
|
|
<PropertyGroupDescription PropertyName="Prefix" />
|
|
</CollectionViewSource.GroupDescriptions>
|
|
</CollectionViewSource>
|
|
<CollectionViewSource Source="{Binding BrushResources}" x:Key="BrushGroups">
|
|
<CollectionViewSource.GroupDescriptions>
|
|
<PropertyGroupDescription PropertyName="Prefix" />
|
|
</CollectionViewSource.GroupDescriptions>
|
|
</CollectionViewSource>
|
|
</UserControl.Resources>
|
|
<StackPanel
|
|
Background="Transparent"
|
|
Margin="16"
|
|
Orientation="Vertical">
|
|
<StackPanel Visibility="Collapsed">
|
|
<TextBlock
|
|
FontSize="14"
|
|
FontWeight="Bold"
|
|
Margin="0,0,0,8"
|
|
Text="颜色资源" />
|
|
<!-- 用 ListView 支持分组 -->
|
|
<ListView
|
|
Height="300"
|
|
ItemTemplate="{StaticResource ColorItemTemplate}"
|
|
ItemsSource="{Binding Source={StaticResource ColorGroups}}"
|
|
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
|
Style="{x:Null}"
|
|
Visibility="Collapsed">
|
|
<ListView.ItemContainerStyle>
|
|
<Style TargetType="ListViewItem">
|
|
<Setter Property="Padding" Value="0" />
|
|
<Setter Property="Margin" Value="0" />
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
|
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
|
<Setter Property="Focusable" Value="False" />
|
|
<Setter Property="IsHitTestVisible" Value="False" />
|
|
</Style>
|
|
</ListView.ItemContainerStyle>
|
|
<ListView.ItemsPanel>
|
|
<ItemsPanelTemplate>
|
|
<WrapPanel
|
|
ItemHeight="60"
|
|
ItemWidth="320"
|
|
Orientation="Horizontal" />
|
|
</ItemsPanelTemplate>
|
|
</ListView.ItemsPanel>
|
|
<ListView.GroupStyle>
|
|
<GroupStyle>
|
|
<GroupStyle.HeaderTemplate>
|
|
<DataTemplate>
|
|
<TextBlock
|
|
FontSize="16"
|
|
FontWeight="Bold"
|
|
Margin="0,8,0,4"
|
|
Text="{Binding Name}" />
|
|
</DataTemplate>
|
|
</GroupStyle.HeaderTemplate>
|
|
</GroupStyle>
|
|
</ListView.GroupStyle>
|
|
</ListView>
|
|
</StackPanel>
|
|
<StackPanel>
|
|
<TextBlock
|
|
FontSize="14"
|
|
FontWeight="Bold"
|
|
Margin="16,12,0,8"
|
|
Text="画刷资源"
|
|
TextWrapping="WrapWithOverflow" />
|
|
<ListView
|
|
Height="300"
|
|
ItemTemplate="{StaticResource BrushItemTemplate}"
|
|
ItemsSource="{Binding Source={StaticResource BrushGroups}}"
|
|
ScrollViewer.HorizontalScrollBarVisibility="Visible"
|
|
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
|
Style="{x:Null}">
|
|
<ListView.ItemContainerStyle>
|
|
<Style TargetType="ListViewItem">
|
|
<Setter Property="Padding" Value="0" />
|
|
<Setter Property="Margin" Value="0" />
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
|
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
|
<Setter Property="Focusable" Value="False" />
|
|
<Setter Property="IsHitTestVisible" Value="False" />
|
|
</Style>
|
|
</ListView.ItemContainerStyle>
|
|
<ListView.ItemsPanel>
|
|
<ItemsPanelTemplate>
|
|
<WrapPanel
|
|
ItemHeight="60"
|
|
ItemWidth="320"
|
|
Orientation="Horizontal" />
|
|
</ItemsPanelTemplate>
|
|
</ListView.ItemsPanel>
|
|
<ListView.GroupStyle>
|
|
<GroupStyle>
|
|
<GroupStyle.HeaderTemplate>
|
|
<DataTemplate>
|
|
<TextBlock
|
|
FontSize="16"
|
|
FontWeight="Bold"
|
|
Margin="0,8,0,4"
|
|
Text="{Binding Name}" />
|
|
</DataTemplate>
|
|
</GroupStyle.HeaderTemplate>
|
|
</GroupStyle>
|
|
</ListView.GroupStyle>
|
|
</ListView>
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</UserControl>
|
|
|