56

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.

The XAML for the window :

<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>
4

5 回答 5

112

您需要将WindowStyle属性设置为,就像我在此答案None中概述的那样

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

您还可以设置AllowsTransparency="True"Background="Transparent"如果您想隐藏整个窗框并建立自己的。

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

您刚刚发布的代码对我来说很好。没有标题栏,虽然因为您指定了 Resize 边框ResizeMode="CanResize"

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

于 2013-03-14T15:32:31.803 回答
13
<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>

上面的代码适用于您的问题“如何使标题栏在 WPF 窗口中消失?”

于 2013-03-14T15:38:29.117 回答
4

尝试将标题高度设置为 0

<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"
    WindowStartupLocation="CenterScreen"
    ResizeMode="CanResize">

 //remove the border, glassframe, but keep the ability to resize
<WindowChrome.WindowChrome>
    <WindowChrome GlassFrameThickness="0" CornerRadius="0" CaptionHeight="0"/>
</WindowChrome.WindowChrome>

<Grid>
    <TextBlock Text="Resizeable Window" HorizontalAlignment="Center" FontSize="30"/>  
</Grid>

于 2019-08-13T16:25:32.053 回答
-1

尝试设置 TitleBarHeight="0"

于 2019-01-04T21:13:11.233 回答
-4

我认为您应该使用 ShowTitleBar="False" 并返回应用程序中的任何位置,无论是在 Xaml 文件中还是在后面的代码中。这应该够了吧

于 2017-07-19T12:04:50.447 回答