首页 > 其他分享 >WPF重写Window标题栏

WPF重写Window标题栏

时间:2023-03-28 14:12:46浏览次数:29  
标签:WPF 标题栏 重写 Window

<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

相关文章

  • windows系统DOS窗口刷新网络
    win+Rcmd回车释放指定适配器的IPv4地址ipconfig/release释放指定适配器的IPv6地址ipconfig/release6更新指定适配器的IPv4地址ipconfig/renew更新指......
  • Conda in Windows under MSYS2 and Zsh 的问题解决
    CondainWindowsunderMSYS2andZsh的问题解决在Window11上使用gitbash安装zsh,并配置p10k主题,主要问题就是prompt中无法显示condaenv;condaactivate/deactivate......
  • 这是一个使用.net 6 基于wpf 、OpencvSharp(opencv的.net wrapper)、ReactiveUI等开发
    这是一个使用.net6基于wpf、OpencvSharp(opencv的.netwrapper)、ReactiveUI等开发的自用工具,主要用来做ReactiveUI与OpencvSharp学习过程中的尝试以及opencv算子参数的......
  • windows下使用docker
    之前一直在Linux上玩docker,这次尝试下在windows上操作docker。做下总结:首先启动dockerdesktop。1、VS中右键-发布项目 2、在dockerfile所在目录下执行dockerbuil......
  • window和linux如何将go代码打包成可执行程序
    前言:在window下代码写好了,如何部署到linux呢,或者怎么打包成exe程序,在window下运行呢?查看正文正文:window下如何打包成exe文件,并运行。打开goland,点击Terminal终端输入......
  • Installing Windows 7 on VirtualBox. Error status: 0xc0000225?
    Today,afterfinallytakingtheplungeintotheLinuxworld(I'mtryingtorefocusmyworktotheRailsecosystem),IinstalledVirtualBoxonLinuxMint13. Si......
  • Windows启动一个FTP站点,让局域网的人访问/写
      现在需要一台局域网的电脑启动一个ftp站点,该电脑需要进行以下步骤:https://blog.csdn.net/m0_50298323/article/details/128404598   ......
  • Windows设置自动登录
    直接修改注册表我发现有的Windows10版本,运行netplwiz,出现的“用户账户”的对话框中并没有以上选项,这可能由于在系统安装或者配置过程的某种设置问题造成的。这种情况应......
  • 小皮Windows web面板漏洞详解
    漏洞简介PhpStudy国内12年老牌公益软件,集安全、高效、功能与一体,已获得全球用户认可安装,运维也高效。支持一键LAMP、LNMP、集群、监控、网站、数据库、FTP、软件中心......
  • Windows _popen 会吃了前后双引号
    Windows_popen函数会吃了前后双引号.例如,"c:/asd/blhost"-u--write-memory0x70010000"c:/asd/asd.bin"会被吃掉前后引号变为c:/asd/blhost"-u--write-me......