---
title: "Get the height/width of Window WPF"  
description: "Get the height/width of Window WPF"  
author: "Mark Devid"  
published: 2014-01-30  
updated: 2014-01-30  
canonical: https://www.mindstick.com/forum/1922/get-the-height-width-of-window-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# Get the height/width of Window WPF

I have the following [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii)

```
<Window x:Class="Netspot.DigitalSignage.Client.MainWindow"       
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"       
Title="MainWindow" WindowStyle="SingleBorderWindow"        
WindowStartupLocation="CenterScreen"       
WindowState="Normal" Closing="Window_Closing">
```

Any attempt to get the height / width return NaN or 0.0

Can [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) a way of getting it ?

These 2 [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best) don't work

## //Method1

```
var h = ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualHeight;var w =
((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualWidth;
```

## //Method2

```
double dWidth = -1;double dHeight = -1;FrameworkElement pnlClient = this.Content as
FrameworkElement;if (pnlClient != null){     dWidth =
pnlClient.ActualWidth;     dHeight =
pnlClient.ActualWidth;}
```

The [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) will not be running [full](https://www.mindstick.com/articles/12893/experience-the-full-power-of-suitecrm) screen.

## Replies

### Reply by Pravesh Singh

Hi Mark,

You can get the width and height that the window was meant to be in the constructor after InitializeComponent has been run, they won't return NaN then, the actual height and width will have to wait until the window has been displayed.

```
When WindowState == Normal You can do this one from Width /
Height after IntializeComponent().When WindowState == Maximized You could get the screen
resolution for this one withSystem.Windows.SystemParameters.PrimaryScreenHeight;System.Windows.SystemParameters.PrimaryScreenWidth;
```


---

Original Source: https://www.mindstick.com/forum/1922/get-the-height-width-of-window-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
