From dedcf4174c8540ee3a912daad2ff13e014e495b1 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期五, 28 三月 2025 16:28:30 +0800
Subject: [PATCH] 优化UI组件;
---
WPFProject/Controls/MainTabControl.xaml | 155 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 120 insertions(+), 35 deletions(-)
diff --git a/WPFProject/Controls/MainTabControl.xaml b/WPFProject/Controls/MainTabControl.xaml
index e2655f1..2950b42 100644
--- a/WPFProject/Controls/MainTabControl.xaml
+++ b/WPFProject/Controls/MainTabControl.xaml
@@ -5,6 +5,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFProject.Controls"
mc:Ignorable="d"
+ Loaded="UserControl_Loaded"
+ Foreground="#51555f"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
@@ -13,37 +15,40 @@
</ResourceDictionary.MergedDictionaries>
<Style TargetType="ListBox" x:Key="ListBoxItemStyle1">
- <Setter Property="Background" Value="{StaticResource MainMenu}"/>
+ <Setter Property="Background" Value="Transparent"/>
+ <Setter Property="Padding" Value="-1"/>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
+ <Setter Property="Foreground" Value="{StaticResource PrimaryColorContract}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
- <Border x:Name="border" Background="{StaticResource MainMenu}"
- Padding="10" Margin="0" BorderThickness="0,0,1,0" BorderBrush="Gray">
- <!-- 鍐呭鍛堢幇鍣� -->
- <StackPanel>
- <ContentPresenter Content="{TemplateBinding Content}"
- ContentStringFormat="{TemplateBinding ContentStringFormat}"
- ContentTemplate="{TemplateBinding ContentTemplate}" />
- </StackPanel>
-
+ <Border x:Name="border" Padding="10,5" BorderBrush="{StaticResource PrimaryColor}"
+ Cursor="Hand"
+ BorderThickness="1,0,0,0"
+ >
+ <ContentPresenter x:Name="cp" Content="{TemplateBinding Content}"
+ContentStringFormat="{TemplateBinding ContentStringFormat}"
+ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
- <Setter TargetName="border" Property="Background" Value="{StaticResource ButtonSelected}" />
+ <Setter TargetName="border" Property="Background"
+ Value="#7093d3"/>
+ <Setter Property="Foreground" Value="#ffff95"/>
</Trigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=(ItemsControl.AlternationIndex)}" Value="0">
- <Setter TargetName="border" Property="BorderThickness" Value="1,0,1,0" />
+ <Setter TargetName="border" Property="BorderThickness" Value="0" />
</DataTrigger>
<Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="border" Property="Background" Value="Red" />
+ <Setter TargetName="border" Property="Background" Value="#7093d3" />
+ <Setter Property="Foreground" Value="{StaticResource SecondPrimaryColorContract}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -55,7 +60,7 @@
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
- <StackPanel HorizontalAlignment="Left" Orientation="Horizontal"/>
+ <VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
@@ -63,15 +68,78 @@
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
- <Image Width="20" Height="20" Margin="5" Source="{Binding Icon}"/>
- <Label x:Name="txt" Visibility="Visible" BorderThickness="0"
- Foreground="{StaticResource PrimaryColorContract}"
- FontWeight="Bold"
- FontSize="16"
+ <!--<Image Width="20" Height="20" Margin="5" Source="{Binding Icon}"/>-->
+ <Label Width="20" Height="20" FontFamily="{StaticResource iconfont}"
+ Padding="0"
+ Foreground="{Binding Foreground,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}"
+ VerticalAlignment="Center"
+ VerticalContentAlignment="Center"
+ FontSize="20" Content="{Binding IconFont}"/>
+ <Label x:Name="txt" BorderThickness="0"
+ Foreground="{Binding Foreground,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}"
+ FontWeight="Bold"
VerticalContentAlignment="Center"
HorizontalAlignment="Left"
Content="{Binding Name}" ToolTip="{Binding Name}"/>
</StackPanel>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <Style TargetType="ListBox" x:Key="ListBoxItemStyle2" BasedOn="{StaticResource ListBoxItemStyle1}">
+ <Setter Property="ItemContainerStyle">
+ <Setter.Value>
+ <Style TargetType="ListBoxItem">
+ <Setter Property="Margin" Value="0"/>
+ <Setter Property="Padding" Value="0"/>
+ <Setter Property="Foreground" Value="{StaticResource PrimaryColorContract}"/>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="ListBoxItem">
+ <Border x:Name="border" Padding="0,10" Margin="0" Cursor="Hand">
+ <ContentPresenter x:Name="cp" Content="{TemplateBinding Content}"
+ContentStringFormat="{TemplateBinding ContentStringFormat}"
+ContentTemplate="{TemplateBinding ContentTemplate}" />
+ </Border>
+
+ <ControlTemplate.Triggers>
+ <Trigger Property="IsSelected" Value="True">
+ <Setter Property="Foreground" Value="#ffff95"/>
+ </Trigger>
+
+ <Trigger Property="IsMouseOver" Value="True">
+ <Setter TargetName="border" Property="Background" Value="#7093d3" />
+ <Setter Property="Foreground" Value="{StaticResource SecondPrimaryColorContract}" />
+ </Trigger>
+ </ControlTemplate.Triggers>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="ItemTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
+ <Label x:Name="txt"
+ Foreground="{Binding Foreground,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem}}"
+ FontWeight="Bold"
+ VerticalContentAlignment="Center"
+ HorizontalContentAlignment="Center"
+ Padding="10,0"
+ VerticalAlignment="Center"
+ BorderThickness="1,0,0,0" BorderBrush="Wheat"
+ Content="{Binding Name}" ToolTip="{Binding Name}"/>
+ </StackPanel>
+
+ <DataTemplate.Triggers>
+ <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem},AncestorLevel=1},
+ Path=(ItemsControl.AlternationIndex)}" Value="0">
+ <Setter TargetName="txt" Property="BorderBrush" Value="Transparent"/>
+ </DataTrigger>
+ </DataTemplate.Triggers>
</DataTemplate>
</Setter.Value>
</Setter>
@@ -86,28 +154,45 @@
<RowDefinition/>
</Grid.RowDefinitions>
- <ListBox Grid.Row="0" x:Name="Menu" Margin="0" Padding="-1"
- Style="{StaticResource ListBoxItemStyle1}"
- BorderBrush="Gray"
- BorderThickness="0,1,0,1"
- Visibility="{Binding MenuVisibility}"
- SelectionChanged="Menu_SelectionChanged"
- SelectedItem="{Binding SelectedMenu}"
- AlternationCount="{Binding MenuItemsCount}" ItemsSource="{Binding MenuItems}">
+ <Border Grid.Row="0" BorderThickness="0,1,0,0" BorderBrush="#93b7ea"
+ Visibility="{Binding MenuVisibility}">
+ <DockPanel Background="Transparent">
+ <Border DockPanel.Dock="Left" BorderThickness="1,1,0,1" Background="Transparent" BorderBrush="{StaticResource PrimaryColor}" Width="50"></Border>
+ <ListBox DockPanel.Dock="Left" Grid.Row="0" x:Name="Menu"
+ Style="{StaticResource ListBoxItemStyle1}" FontSize="16"
+ BorderBrush="{StaticResource PrimaryColor}"
+ BorderThickness="1"
+ SelectionChanged="Menu_SelectionChanged"
+ SelectedItem="{Binding SelectedMenu}"
+ AlternationCount="{Binding MenuItems.Count}" ItemsSource="{Binding MenuItems}">
- </ListBox>
+ </ListBox>
+ <Border DockPanel.Dock="Left" BorderThickness="0,1,1,1" BorderBrush="{StaticResource PrimaryColor}"></Border>
+ </DockPanel>
+ </Border>
- <ListBox Grid.Row="1" x:Name="SubMenu" Margin="0" Padding="-1"
- Style="{StaticResource ListBoxItemStyle1}"
+
+ <Border Grid.Row="1" BorderThickness="0,1" BorderBrush="#93b7ea"
+ Visibility="{Binding MenuVisibility}">
+ <DockPanel Background="Transparent">
+ <Border Margin="1,1,0,1" DockPanel.Dock="Left" Background="Transparent" Width="50"></Border>
+ <ListBox Grid.Row="1" x:Name="SubMenu" Margin="0" FontSize="14"
+ Style="{StaticResource ListBoxItemStyle2}"
BorderBrush="Gray"
Visibility="{Binding MenuVisibility}"
- SelectedItem="{Binding SelectedSubMenu}" AlternationCount="{Binding SubMenuItemsCount}"
+ SelectedItem="{Binding SelectedSubMenu}" AlternationCount="{Binding SubMenuItems.Count}"
SelectionChanged="SubMenu_SelectionChanged"
-BorderThickness="0,0,0,1" ItemsSource="{Binding SubMenuItems}">
- </ListBox>
+BorderThickness="0" ItemsSource="{Binding SubMenuItems}" >
+ </ListBox>
+ </DockPanel>
+ </Border>
- <Border x:Name="page" Grid.Row="2" BorderThickness="0" Margin="0" Padding="0">
-
+
+
+
+
+ <Border x:Name="page" Grid.Row="2" BorderThickness="0" Margin="0" Background="White" Padding="0">
+
</Border>
</Grid>
</UserControl>
--
Gitblit v1.9.1