<Window x:Class="License.UI.DetailsInterface" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:License.UI" mc:Ignorable="d" xmlns:shell="clr-namespace:System.Windows.Shell;assembly=PresentationFramework" Height="310" Width="500" ResizeMode="NoResize" WindowStartupLocation="CenterOwner"> <Window.Resources> <ResourceDictionary> <Style x:Key="btn_nap" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border Background="{TemplateBinding Background}"> <ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"></ContentPresenter> </Border> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="FontSize" Value="12"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Foreground" Value="Black"></Setter> <Setter Property="Background" Value="Transparent"/> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Foreground" Value="White"/> <Setter Property="Background" Value="Red"/> </Trigger> </Style.Triggers> </Style> </ResourceDictionary> </Window.Resources> <shell:WindowChrome.WindowChrome> <shell:WindowChrome CaptionHeight="35" x:Name="windowChrome" CornerRadius="0" GlassFrameThickness="0"/> </shell:WindowChrome.WindowChrome> <Grid> <Grid.RowDefinitions> <RowDefinition Height="30"/> <RowDefinition/> </Grid.RowDefinitions> <Grid Grid.Row="0" x:Name="TitleBlock_Grid" Panel.ZIndex="1"> <!- 标题栏内容-!> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <Button WindowChrome.IsHitTestVisibleInChrome="True" x:Name="btn_Close" Content="✕" Style="{StaticResource btn_nap}" HorizontalAlignment="Right" Click="btn_Close_Click" Height="30" Width="30"/> </StackPanel> <TextBlock x:Name="textBlock" Text="{DynamicResource MenuHelpActivate}" HorizontalAlignment="Left" Margin="10,8,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="87"/> </Grid> <Grid Grid.Row="1"> <!- Body内容 -!> </Grid> </Grid> </Window>
标签:WPF,标题栏,重写,Window From: https://www.cnblogs.com/anjingdian/p/17264951.html