1.wpf自定义窗口:
WindowChrome类描述:https://msdn.microsoft.com/zh-cn/library/system.windows.shell.windowchrome.aspx
示例样式效果:
1.设置GlassFrameThickness=0 隐藏默认标题栏
2.最大化最小化不会盖住任务栏
<Window x:Class="WindowChromeTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
xmlns:local="clr-namespace:WindowChromeTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="local:MainWindow">
<Setter Property="shell:WindowChrome.WindowChrome">
<Setter.Value>
<shell:WindowChrome
CaptionHeight="50"
GlassFrameThickness="0"
CornerRadius="0"
ResizeBorderThickness="2"
></shell:WindowChrome>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MainWindow}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="Orange">
<StackPanel Orientation="Horizontal">
<Button shell:WindowChrome.IsHitTestVisibleInChrome="True" Content="Test Button" Click="Button_Click"></Button>
</StackPanel>
</Border>
<Border Grid.Row="1" Background="White">
<ContentPresenter Content="{TemplateBinding Content}"></ContentPresenter>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<TextBlock Text="asdasdf"></TextBlock>
</Window>