Files
ShrlAlgoToolkit/NeoUI/NeoUITest/IconsWindow.xaml

132 lines
5.3 KiB
Plaintext
Raw Normal View History

2025-08-20 12:10:35 +08:00
<n:NeoWindow
Height="450"
2025-08-24 13:49:55 +08:00
Title="图标预览"
2025-08-20 12:10:35 +08:00
Width="820"
d:DataContext="{d:DesignInstance Type=local:IconsWindow}"
mc:Ignorable="d"
x:Class="NeoUITest.IconsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:NeoUITest"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:n="https://github.com/ShrlAlgo/NeoUI"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- 第一行: 搜索框 -->
<Border
BorderBrush="LightGray"
BorderThickness="0,0,0,1"
Grid.Row="0"
Padding="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox
FontSize="14"
Grid.Column="1"
Padding="5"
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
VerticalContentAlignment="Center">
<n:InputAssist.Suffix>
<n:IconElement
FontSize="18"
Foreground="Gray"
Margin="0,0,10,0"
Symbol="Search"
VerticalAlignment="Center" />
</n:InputAssist.Suffix>
</TextBox>
</Grid>
</Border>
<!-- 第二行: 选中图标信息和复制代码 -->
<Border
BorderBrush="LightGray"
BorderThickness="0,0,0,1"
Grid.Row="1"
Padding="10">
<n:FlexibleRowPanel LayoutMode="Auto">
2025-08-24 13:49:55 +08:00
<TextBlock Foreground="{DynamicResource TextPrimaryBrush}"
2025-08-20 12:10:35 +08:00
FontWeight="Bold"
Text="选中图标:"
VerticalAlignment="Center" />
<!-- 确保绑定是 OneWay因为我们只从后台更新UI -->
<TextBox
FontWeight="Bold"
2025-08-24 13:49:55 +08:00
Foreground="{DynamicResource PrimaryNormalBrush}"
2025-08-20 12:10:35 +08:00
IsReadOnly="True"
Margin="10,0"
Padding="5"
Text="{Binding SelectedSymbolName, Mode=OneWay, FallbackValue='请选择一个图标...'}"
VerticalAlignment="Center"
n:FlexibleRowPanel.IsFill="True" />
<Button
Click="CopyCode_Click"
Content="复制代码"
Padding="10,5"
VerticalAlignment="Center" />
<n:ColorPicker
Margin="10,0,0,0"
VerticalAlignment="Center"
x:Name="ColorPicker" />
</n:FlexibleRowPanel>
</Border>
<!-- 第三行: 图标浏览器 -->
<ListBox
Grid.Row="2"
ItemsSource="{Binding SymbolCollectionView}"
Name="IconItemsControl"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectionChanged="IconItemsControl_SelectionChanged">
<ListBox.Foreground>
<SolidColorBrush Color="{Binding ElementName=ColorPicker, Path=SelectedColor}" />
</ListBox.Foreground>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ItemHeight="80" ItemWidth="80" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel HorizontalAlignment="Center">
<n:IconElement
FontSize="32"
Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}, Path=Foreground}"
Symbol="{Binding}"
ToolTip="{Binding}" />
<TextBlock
FontSize="12"
HorizontalAlignment="Center"
Margin="0,5,0,0"
Text="{Binding}"
TextWrapping="Wrap"
ToolTip="{Binding}"
VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
<!--<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#CCE8FF" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>-->
</ListBox>
</Grid>
</n:NeoWindow>