Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried with removing title bar using WindowStyle="None"

But I need to to show and hide the title bar in WPF by mouse over. So how can I proceed to do this in xaml code?
Posted
Updated 11-Oct-15 7:21am
v2

1 solution

Hi,
You can achieve this using MouseLeave and MouseEnter events of the WPF Window, But this solution will create a fluctuation when you move cursor near to title bar. So I suggest you to use Mahapps.Metro - a UI toolkit for WPF. It provides extended properties for WPF window. Follow the steps provided in the above link.
And Add two events MouseLeave, MouseEnter to the WPF window. Use the below code in respective events.
MouseEnter event:
C#
private void Window_MouseEnter(object sender, MouseEventArgs e)
{
    this.ShowTitleBar = true;
    this.ShowCloseButton = true;
    this.ShowMinButton = true;
    this.ShowMaxRestoreButton = true;
}

MouseLeave event:
C#
private void Window_MouseEnter(object sender, MouseEventArgs e)
{
    this.ShowTitleBar = false;
    this.ShowCloseButton = false;
    this.ShowMinButton = false;
    this.ShowMaxRestoreButton = false;
}

Now, Add Following properties to the WPF window in xaml,
XML
<Controls:metrowindow x:class="CP1038562.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        Title="MainWindow" ShowTitleBar="False" ShowMaxRestoreButton="False" ShowMinButton="False" ShowCloseButton="False" Height="350" Width="525" MouseEnter="Window_MouseEnter" BorderBrush="Blue"  BorderThickness="2" MouseLeave="Window_MouseLeave">
</Controls:metrowindow>

Build & Run.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900