Abdul Manaf
Abdul Manaf

Reputation: 5003

Display wpf window on top of the screen

I am developing a WPF application. I need to to display a window on top of the screen like a window taskbar.

This is my xaml code:

<Window x:Class="testProject.Notification.TestWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:testProject.Notification"
        mc:Ignorable="d"
        Title="TestWindow" Height="80" Topmost="True" ResizeMode="NoResize" WindowStyle="None">
    <Grid Background="Blue"/>
</Window>

I need a bluewindow like below(screen shot from mac osx application):

enter image description here

Upvotes: 4

Views: 2011

Answers (1)

Mohit S
Mohit S

Reputation: 14064

This will do the trick for you

<Window x:Class="AtDTopCorner.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow"
        Height="35"
        WindowStyle="None"
        WindowStartupLocation="Manual"
        Top="5"
        Left="0"
        AllowsTransparency="True"
        Background="Blue"
        Width="{Binding Source={x:Static SystemParameters.FullPrimaryScreenWidth}}">
</Window>

Upvotes: 4

Related Questions