WPF : Maximize window with WindowState Problem (application will hide windows taskbar)

Pouyan picture Pouyan · Jul 31, 2011 · Viewed 27.8k times · Source

I have set my main window state to "Maximized" but the problem is my application will fill the whole screen even task bar. what am i doing wrong ? I'm using windows 2008 R2 with resolution : 1600 * 900

Here is the Xaml :

<Window x:Class="RadinFarazJamAutomationSystem.wndMain"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:RadinFarazJamAutomationSystem"
     xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    Title="MyName"  FontFamily="Tahoma" FontSize="12" Name="mainWindow"  WindowState="Maximized"   xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:my="clr-namespace:RadinFarazJamAutomationSystem.Calendare.UC" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  Loaded="mainWindow_Loaded" FlowDirection="LeftToRight"
    ResizeMode="NoResize" Closed="mainWindow_Closed">

Answer

Yiğit Yener picture Yiğit Yener · Jul 31, 2011

You can set the MaxHeight property of that window to SystemParameters.MaximizedPrimaryScreenHeight using the constructor.

public MainWindow()
{
    InitializeComponent();
    this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
}