How to make title bar disappear in WPF window?
Asked Answered
P

6

67

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>
Pelt answered 14/3, 2013 at 15:20 Comment(5)
What @HighCore said....The code in the posts you linked works just fine.Adsorbate
WindowStyle="None" isn't that exactly what you were looking for???Torhert
@SandraWalters it's funny and ironic (since there were hordes of developers complaining that XAML was too unreadable) How in the end I feel more comfortable reading XAML than english... does it happen to you?Nasser
@HighCore Reading Xaml makes perfect sense; it's reading VB that makes me want to claw my eyes out :)Adsorbate
If I understand correctly, code does what you want. But if you also want it to be maximized, add WindowState="Maximized"...Tanah
W
127

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

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

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

Update based on code added to question

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"

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)

Weakfish answered 14/3, 2013 at 15:32 Comment(3)
It does say WindowStyle = "None" after the width. I have changed my margins to 0, however it stills says window in the top left corner and I cannot move my grid up to take up that space. ThanksPelt
@StewartStoakes Could you post a screenshot of what your window looks like? It would also help if you set the Background color of the Grid so you can see exactly where the boundaries are. I copied and pasted the code in your question into a new project and the Title stays hidden just fine (Also, your Title property is blank so I'm not sure where it's getting "Window" from... are you sure you're only showing this one Window and a 2nd one isn't getting displayed?)Weakfish
Perfect! AllowsTransparency="True" and Background="Transparent" are just what I needed to make a custom splash screen. :)Farmland
G
14
<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>

The above code works fine for your question "How to make title bar dissappear in WPF window?"

Giesecke answered 14/3, 2013 at 15:38 Comment(2)
Set AllowsTransparency="True" and set the borderbrush and borderthickness. This will show the border. WindowStyle="None" ResizeMode="CanResize" AllowsTransparency="True" BorderThickness="1" BorderBrush="Black"Giesecke
Set ResizeMode=CanResizeWithGrip if you want to be able to resizeGiesecke
U
5

try to set the caption height to 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>

Upmost answered 13/8, 2019 at 16:25 Comment(0)
B
5
<Window  WindowStyle="None" >

will remove the title bar of the window,

if you just want to add a header to your window where you can dragmove it just make a grid row for the header

enter image description here

this is the code i have used for make the header of the page

xaml

    <Grid Grid.Row="0" Background="#FF486A9B"    MouseDown="Window_MouseDown"  >

c#

   private void Window_MouseDown(object sender, MouseButtonEventArgs e)
    {
        if (e.ChangedButton == MouseButton.Left)
            this.DragMove();
    }





  
Bianca answered 24/3, 2022 at 16:14 Comment(0)
R
-2

Try setting TitleBarHeight="0"

Recognition answered 4/1, 2019 at 21:13 Comment(2)
When adding an answer to an older question with existing answers it is helpful to explain how your answer differs and why it might be better.Sokoto
There is no TitleBarHeight property on Window.Odeliaodelinda
F
-5

I think you should play with ShowTitleBar="False" and back anywhere within your application, either in the Xaml file or in the code behind. That should do the trick

Fire answered 19/7, 2017 at 12:4 Comment(1)
There is no such property ShowTitleBar on WindowLandslide

© 2022 - 2024 — McMap. All rights reserved.