- 概述:
因为我要做的是无边框,且系统按钮与图标文字在同一水平背景上,原有的系统按钮太丑了,所以我重新自定义了最小化、最大化、关闭这三个系统按钮,用图片按钮切换来代替原有的:
效果如下图:
App.xaml页面代码:
<Application x:Class="WPF_Client.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPF_Client"
StartupUri="LoginWindow.xaml">
<Application.Resources>
<!--自定义系统最小化button-->
<Style x:Key="Minbtn" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid Cursor="Hand">
<Border x:Name="_Border" BorderBrush="Transparent" CornerRadius="5" BorderThickness="0">
<Border.Background>
<ImageBrush ImageSource="Images/最小化.png"/>
</Border.Background>
</Border>
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment