2013-03-14 103 views
24

我知道这已经被问过,但我试过的答案@如何使标题栏在WPF窗口中消失?

既不工作,标题栏文字坐在那里和IM不能动我的网格直到窗口的顶部,以便网格占据整个窗口。我对WPF相当陌生,而且我对一些事情做得很好,但我坚持这一点,谢谢。

的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> 
+6

发表您的XAML。我懒得读这个。 – 2013-03-14 15:22:34

+0

@HighCore说什么....你链接的帖子中的代码工作得很好。 – 2013-03-14 15:30:28

+1

'WindowStyle =“None”'是不是你正在寻找的? – Nolonar 2013-03-14 15:32:29

回答

55

您需要的WindowStyle属性设置为None,就像我在this answer

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

您还可以设置AllowsTransparency="True"Background="Transparent"概括,如果你想隐藏整个窗口框架并构建自己的窗体。基于代码

更新加入到质疑

您刚刚发布的代码工作正常,我。没有标题栏,虽然是因为你指定ResizeMode="CanResize"

你确实有在你的窗口顶部的一些空白调整大小的边界,但是那是因为你指定的上边距为您的滑块和文本框(当您指定有4个数字的保证金,这是不言而喻左,上,右,下那么第2个数字就是你的上边距)

+0

它说宽度后WindowStyle =“无”。我已将边距改为0,但它仍然显示左上角的窗口,我无法移动网格以占据该空间。谢谢 – 2013-03-14 16:00:16

+0

@StewartStoakes你可以发布你的窗口看起来像一个截图吗?如果你设置网格的背景颜色,这样也可以帮助你准确地看到边界的位置。我复制并粘贴在你的问题的代码到一个新的项目和标题保持隐藏就好了(而且,你的'Title'属性是空白,所以我不知道在哪里,它变得“窗口”从......你确定你只显示这一个窗口和第二个没有显示?) – Rachel 2013-03-14 16:06:46

+1

完美! AllowsTransparency =“True”'和'Background =“Transparent”'正是我制作自定义启动画面所需要的。:) – 2014-07-11 14:08:38

6
<Window x:Class="BorderlessWindow.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="350" Width="525" 
     WindowStyle="None" 
     BorderBrush="Black" 
     BorderThickness="5" 
     AllowsTransparency="True" 
     > 
    <Grid> 
     <TextBlock Text="Title Less Window" HorizontalAlignment="Center" FontSize="15" Margin="10" /> 
    </Grid> 
</Window> 

上面的代码工作正常,你的问题:“如何使标题栏dissappear在WPF窗口? “

+0

Set AllowsTransparency =“True”,并设置边界刷和borderthickickness。这将显示边框。 WindowStyle =“None”ResizeMode =“CanResize”AllowsTransparency =“True”BorderThickness =“1”BorderBrush =“Black” – isakavis 2013-03-14 15:43:14

+0

如果您想调整大小,请设置ResizeMode = CanResizeWithGrip – isakavis 2013-03-14 15:45:14

0

我想你应该ShowTitleBar你的应用程序中=“假”,后踢任何位置,无论是在XAML文件或在后面的代码。这应该做的伎俩

+0

Window上没有这样的属性'ShowTitleBar' ' – 2017-10-13 01:11:10

相关问题