优化自定义窗口标题栏
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="WindowHeaderTest" Height="450" Width="800" Foreground="White">
|
Title="WindowHeaderTest" Height="450" Width="800" Foreground="White">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<deedy:WindowHeader DockPanel.Dock="Top" FontSize="18" HoverBrush="Wheat">
|
<deedy:WindowHeader>
|
||||||
<Button Content="按钮"/>
|
<Button Content="按钮"/>
|
||||||
</deedy:WindowHeader>
|
</deedy:WindowHeader>
|
||||||
<Grid/>
|
<Grid/>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<Setter Property="Height" Value="32"/>
|
<Setter Property="Height" Value="32"/>
|
||||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
||||||
|
<Setter Property="DockPanel.Dock" Value="Top"/>
|
||||||
<Setter Property="Padding" Value="6"/>
|
<Setter Property="Padding" Value="6"/>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
@@ -34,27 +35,27 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Border x:Name="IconView" Width="{Binding ActualHeight, ElementName=Root}">
|
<Border x:Name="IconView" Width="{Binding ActualHeight, ElementName=Root}">
|
||||||
<Image Margin="{TemplateBinding Padding}" VerticalAlignment="Center" HorizontalAlignment="Center"
|
<Image Margin="{TemplateBinding Padding}" VerticalAlignment="Center" HorizontalAlignment="Center"
|
||||||
Source="{Binding Icon, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
|
Source="{Binding Icon, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
|
||||||
</Border>
|
</Border>
|
||||||
<TextBlock x:Name="TitleBar" Grid.Column="1" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}"
|
<TextBlock x:Name="TitleBar" Grid.Column="1" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}"
|
||||||
Margin="{TemplateBinding Padding}" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
Margin="{TemplateBinding Padding}" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
Text="{Binding Title, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
|
Text="{Binding Title, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
|
||||||
<Border x:Name="Container" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
<Border x:Name="Container" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||||
<StackPanel x:Name="Controller" Grid.Column="3" Orientation="Horizontal">
|
<StackPanel x:Name="Controller" Grid.Column="3" Orientation="Horizontal">
|
||||||
<Button x:Name="Minimize" VerticalAlignment="Stretch" Style="{StaticResource controlButtonStyle}" Cursor="Hand"
|
<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">
|
<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"/>
|
<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>
|
</Viewbox>
|
||||||
</Button>
|
</Button>
|
||||||
<Button x:Name="Maximize" VerticalAlignment="Stretch" Style="{StaticResource controlButtonStyle}" Cursor="Hand"
|
<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">
|
<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"/>
|
<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>
|
</Viewbox>
|
||||||
</Button>
|
</Button>
|
||||||
<Button x:Name="CloseWin" VerticalAlignment="Stretch" Style="{StaticResource controlButtonStyle}" Cursor=""
|
<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">
|
<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"/>
|
<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>
|
</Viewbox>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace Deedy
|
|||||||
{
|
{
|
||||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(WindowHeader), new FrameworkPropertyMetadata(typeof(WindowHeader)));
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(WindowHeader), new FrameworkPropertyMetadata(typeof(WindowHeader)));
|
||||||
BackgroundProperty.OverrideMetadata(typeof(WindowHeader), new FrameworkPropertyMetadata(Brushes.DimGray));
|
BackgroundProperty.OverrideMetadata(typeof(WindowHeader), new FrameworkPropertyMetadata(Brushes.DimGray));
|
||||||
|
FontSizeProperty.OverrideMetadata(typeof(WindowHeader), new FrameworkPropertyMetadata(16.0));
|
||||||
}
|
}
|
||||||
public Brush HoverBrush
|
public Brush HoverBrush
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user