WPF窗口样式的比较

WPF窗口样式的比较

1.WPF默认Window窗口 带有图标 标题栏 最小最大化推出按钮
csharp 复制代码
<Window x:Class="GlowWindowDemo.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:local="clr-namespace:GlowWindowDemo"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        
    </Grid>
</Window>
2.HandyControl拓展的Window窗口 隐藏了默认图标
csharp 复制代码
<hc:Window
    x:Class="GlowWindowDemo.Window3"
    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:hc="https://handyorg.github.io/handycontrol"
    xmlns:local="clr-namespace:GlowWindowDemo"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="Window3"
    Width="800"
    Height="450"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">
    <Grid />
</hc:Window>

新增属性:

3.HandyControl拓展的GlowWindow窗口 窗口边框可设置显示颜色 辉光效果
csharp 复制代码
<hc:GlowWindow
    x:Class="GlowWindowDemo.Window2"
    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:hc="https://handyorg.github.io/handycontrol"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="Window2"
    Width="800"
    Height="450"
    ActiveGlowColor="{DynamicResource PrimaryColor}"
    Background="{DynamicResource MainContentBackgroundBrush}"
    InactiveGlowColor="{DynamicResource DangerColor}"
    Style="{StaticResource WindowGlow}"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">
    <Border Margin="10" Background="{DynamicResource LightInfoBrush}" />
</hc:GlowWindow>
4.GlowWindow非客户端区域的设置 可自定义标题栏内容 设置显示的Log 文字等
csharp 复制代码
<hc:GlowWindow
    x:Class="GlowWindowDemo.Window4"
    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:hc="https://handyorg.github.io/handycontrol"
    xmlns:local="clr-namespace:GlowWindowDemo"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="Window4"
    Width="800"
    Height="450"
    Background="{DynamicResource RegionBrush}"
    ShowTitle="False"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">

    <!--  标题栏内容  -->
    <hc:GlowWindow.NonClientAreaContent>

        <StackPanel Background="{DynamicResource DarkInfoBrush}" Orientation="Horizontal">
            <hc:OutlineText
                Margin="3"
                Fill="{DynamicResource ColorPickerRainbowBrush}"
                FontSize="32"
                FontWeight="Bold"
                StrokeThickness="2"
                Text="Hello WPF" />
        </StackPanel>
    </hc:GlowWindow.NonClientAreaContent>
    <Grid />
</hc:GlowWindow>

注:当设置标题栏背景颜色时,鼠标在标题栏区域无法拖动窗口移动!!!


不设置标题栏背景颜色时,鼠标在标题栏区域可拖动窗口移动!!!

相关推荐
三千道应用题3 小时前
WPF&C#超市管理系统(4)入库管理
c#·wpf
freesheep72018 小时前
WPF使用PreviewTextInput事件限制用户输入
c#·wpf
c#上位机2 天前
wpf之ControlTemplate
wpf
kyranhan4 天前
WPF,窗口拖动事件与窗口内控件点击事件
wpf
孟婆来包棒棒糖~5 天前
SpringCloude快速入门
分布式·后端·spring cloud·微服务·wpf
Humbunklung5 天前
C# WPF 实现读取文件夹中的PDF并显示其页数
pdf·c#·wpf·npoi·gemini·itext
wangnaisheng5 天前
【WPF】NumericUpDown的用法
wpf
步、步、为营5 天前
.NET 9 RC1 正式发布
.net·wpf
界面开发小八哥7 天前
界面组件DevExpress WPF中文教程:Grid - 如何过滤节点?
.net·wpf·界面控件·devexpress·ui开发
I'mSQL7 天前
C#与WPF使用mvvm简单案例点击按钮触发弹窗
开发语言·c#·wpf