Browse Source

隐藏默认标题栏,设置自定义标题栏

master
忱 沈 4 years ago
parent
commit
d833d26c0d
  1. 30
      MainWindow.xaml

30
MainWindow.xaml

@ -12,6 +12,7 @@
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="30" UseAeroCaptionButtons="False"></WindowChrome>
</WindowChrome.WindowChrome>
<!--模板-->
<Window.Resources>
<Style x:Key="RadioButtonStyle" TargetType="{x:Type RadioButton}">
@ -91,8 +92,31 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Button_Menu" TargetType="{x:Type Button}">
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="MyBackgroundElement" BorderBrush="{x:Null}" BorderThickness="0">
<ContentPresenter x:Name="ButtonContentPresenter" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="MyBackgroundElement" Property="Background" Value="#FFFFFFFF"/>
<Setter TargetName="MyBackgroundElement" Property="Opacity" Value="0.7"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Cursor" Value="Hand" />
</Style>
</Window.Resources>
<Grid>
<!--工具栏-->
<Rectangle HorizontalAlignment="Left" Width="140" Fill="#FFCCCCCC"/>
@ -112,10 +136,8 @@
<!--自定义标题栏-->
<Border HorizontalAlignment="Stretch" Height="35" Margin="140,0,0,0" VerticalAlignment="Top" Background="#FFE6E6E6" />
<Button Content="➖" HorizontalAlignment="Right" Height="35" Margin="0,0,0,0" VerticalAlignment="Top" Width="40" Click="Button_Click" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FF100F0F"
BorderThickness="0,0,0,0" FontSize="24" OpacityMask="#FFA4A4A4" WindowChrome.IsHitTestVisibleInChrome="True" VerticalContentAlignment="Center" Padding="0,0,0,0" FontWeight="Bold" FontStyle="Normal"/>
<Button Content="Button" HorizontalAlignment="Left" Height="190" Margin="185,155,0,0" VerticalAlignment="Top" Width="250"/>
<Button Style="{StaticResource Button_Menu}" Content="➖" HorizontalAlignment="Right" Height="35" Margin="0,0,0,0" VerticalAlignment="Top" Width="45" Click="Button_Click" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FF100F0F"
BorderThickness="0,0,0,0" FontSize="24" OpacityMask="#FFA4A4A4" WindowChrome.IsHitTestVisibleInChrome="True" VerticalContentAlignment="Center" Padding="0,0,0,0" FontWeight="Bold" FontStyle="Normal" Cursor="Hand"/>
<!--用户窗体-->
<Grid Grid.ColumnSpan="2">