如何使 WPF 窗口中的标题栏消失? [英] How to make title bar disappear in WPF window?

查看:82
本文介绍了如何使 WPF 窗口中的标题栏消失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以前有人问过这个问题,但我已经尝试过回答:

I know this has been asked before but I've tried answers:

两者都不起作用,标题栏文本位于那里,我无法将我的网格向上移动到窗口顶部,以便网格占据整个窗口.我被困在这个问题上.

and neither work, the title bar text sits there and im unable to move my grid up to the top of the window so that the grid takes up the whole window. I' am stuck on this.

窗口的 XAML :

<Window x:Class="PlayWPF.TimerSlideWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="" Height="95" Width="641" WindowStyle="None" 
    ResizeMode="CanResize" AllowsTransparency="False">
   <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
       <Slider Height="42" HorizontalAlignment="Left" Margin="10,14,0,0" 
               Name="sldTime" VerticalAlignment="Top" Width="495" />
       <TextBox FontSize="18" Height="29" HorizontalAlignment="Left" 
                Margin="510,10,0,0" Name="txtTime" Text="00:00:00" 
                TextAlignment="Center" VerticalAlignment="Top" Width="93" />
   </Grid>
</Window>

推荐答案

您需要将 WindowStyle 属性设置为 None,就像我在 这个答案

You need to set the WindowStyle property to None, like I outlined in this answer

<Window ...
    WindowStyle="None"
    WindowState="Maximized"
    WindowStartupLocation="CenterScreen">

如果您希望隐藏整个窗口框架并构建自己的框架,您还可以设置 AllowsTransparency="True"Background="Transparent".

You can also set AllowsTransparency="True" and Background="Transparent" if you wish to hide the entire window frame and build your own.

根据添加到问题的代码进行更新

您刚刚发布的代码对我来说很好用.没有标题栏,尽管有一个 Resize 边框,因为您指定了 ResizeMode="CanResize"

The code you just posted works fine for me. There is no title bar, although there is a Resize border because you specified ResizeMode="CanResize"

您的窗口顶部确实有一些空白,但那是因为您为 Slider 和 TextBox 指定了一个顶部边距(当您指定一个带有 4 个数字的边距时,它会依次向左、上、右、下,因此第二个数字是您的最高利润率)

You do have some whitespace at the top of your window, but that is because you specified a top Margin for your Slider and TextBox (When you specify a Margin with 4 numbers, it goes Left, Top, Right, Bottom so the 2nd number is your Top Margin)

这篇关于如何使 WPF 窗口中的标题栏消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆