优化自定义窗口标题栏

This commit is contained in:
zengwenjie
2025-09-29 14:18:02 +08:00
parent 2749813c73
commit 3e0d8dc6c5
3 changed files with 9 additions and 7 deletions

View File

@@ -8,7 +8,7 @@
mc:Ignorable="d"
Title="WindowHeaderTest" Height="450" Width="800" Foreground="White">
<DockPanel>
<deedy:WindowHeader DockPanel.Dock="Top" FontSize="18" HoverBrush="Wheat">
<deedy:WindowHeader>
<Button Content="按钮"/>
</deedy:WindowHeader>
<Grid/>

View File

@@ -6,6 +6,7 @@
<Setter Property="Height" Value="32"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="DockPanel.Dock" Value="Top"/>
<Setter Property="Padding" Value="6"/>
<Setter Property="Template">
<Setter.Value>
@@ -42,19 +43,19 @@
<Border x:Name="Container" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<StackPanel x:Name="Controller" Grid.Column="3" Orientation="Horizontal">
<Button x:Name="Minimize" VerticalAlignment="Stretch" Style="{StaticResource controlButtonStyle}" Cursor="Hand"
Padding="{TemplateBinding Padding}" Width="{Binding ActualHeight, ElementName=Root}">
Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" Padding="{TemplateBinding Padding}">
<Viewbox Stretch="Uniform">
<Path Width="1024" Height="1024" Stroke="{TemplateBinding Foreground}" Fill="{TemplateBinding Foreground}" Data="M917.333333 554.666667H106.666667a21.333333 21.333333 0 0 1 0-42.666667h810.666666a21.333333 21.333333 0 0 1 0 42.666667z"/>
</Viewbox>
</Button>
<Button x:Name="Maximize" VerticalAlignment="Stretch" Style="{StaticResource controlButtonStyle}" Cursor="Hand"
Padding="{TemplateBinding Padding}" Width="{Binding ActualHeight, ElementName=Root}">
Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" Padding="{TemplateBinding Padding}">
<Viewbox Stretch="Uniform">
<Path Width="1024" Height="1024" Stroke="{TemplateBinding Foreground}" Fill="{TemplateBinding Foreground}" Data="M714.666667 256H138.666667a53.393333 53.393333 0 0 0-53.333334 53.333333v576a53.393333 53.393333 0 0 0 53.333334 53.333334h576a53.393333 53.393333 0 0 0 53.333333-53.333334V309.333333a53.393333 53.393333 0 0 0-53.333333-53.333333z m10.666666 629.333333a10.666667 10.666667 0 0 1-10.666666 10.666667H138.666667a10.666667 10.666667 0 0 1-10.666667-10.666667V309.333333a10.666667 10.666667 0 0 1 10.666667-10.666666h576a10.666667 10.666667 0 0 1 10.666666 10.666666z m213.333334-746.666666v565.333333a21.333333 21.333333 0 0 1-42.666667 0V138.666667a10.666667 10.666667 0 0 0-10.666667-10.666667H320a21.333333 21.333333 0 0 1 0-42.666667h565.333333a53.393333 53.393333 0 0 1 53.333334 53.333334z"/>
</Viewbox>
</Button>
<Button x:Name="CloseWin" VerticalAlignment="Stretch" Style="{StaticResource controlButtonStyle}" Cursor=""
Padding="{TemplateBinding Padding}" Width="{Binding ActualHeight, ElementName=Root}">
Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" Padding="{TemplateBinding Padding}">
<Viewbox Stretch="Uniform">
<Path Width="1024" Height="1024" Stroke="{TemplateBinding Foreground}" Fill="{TemplateBinding Foreground}" Data="M542.173333 512l347.58-347.58a21.333333 21.333333 0 1 0-30.173333-30.173333L512 481.826667 164.42 134.246667a21.333333 21.333333 0 0 0-30.173333 30.173333L481.826667 512l-347.58 347.58a21.333333 21.333333 0 0 0 30.173333 30.173333L512 542.173333l347.58 347.58a21.333333 21.333333 0 0 0 30.173333-30.173333z"/>
</Viewbox>

View File

@@ -28,6 +28,7 @@ namespace Deedy
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WindowHeader), new FrameworkPropertyMetadata(typeof(WindowHeader)));
BackgroundProperty.OverrideMetadata(typeof(WindowHeader), new FrameworkPropertyMetadata(Brushes.DimGray));
FontSizeProperty.OverrideMetadata(typeof(WindowHeader), new FrameworkPropertyMetadata(16.0));
}
public Brush HoverBrush
{