如何在WPF中删除窗口边框?

时间:2021-04-26 09:35:14

标签: wpf xaml window

这是通过 WPF 模板创建项目时的默认窗口:

void display(unsigned n, int printzeroes)
{
    unsigned mask = 1 << (CHAR_BIT * sizeof(mask) - 1);
    int print = printzeroes;

    while(mask)
    {
        if(n & mask)
        {
            print = 1;
        }
        if(print) printf("%d", !!(n & mask));
        mask >>= 1;
    }
}

默认窗口有黑色边框。 enter image description here

如何删除?

1 个答案:

答案 0 :(得分:1)

您可以设置Window.WindowStyle="ToolWindow"。你还是会有阴影的。

<Window x:Class="Chaco.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:Chaco"
        mc:Ignorable="d"
        WindowStyle="ToolWindow"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Button x:Name="ButtonMain" Content="Main" Width="100" Height="50" Background="White">
        </Button>
    </Grid>
</Window>

或者你可以设置WindowChrome.WindowChrome附加属性,设置GlassFrameThickness="0"也会去除阴影:

<WindowChrome.WindowChrome>
    <WindowChrome GlassFrameThickness="0"/>
</WindowChrome.WindowChrome>

另一种方法是通过窗口设置 WindowStyle="None"AllowsTransparency="True"

相关问题