2013-03-14 87 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

相關問題