title: Problems with binding to Window Height and Width
body: <p>I have some problems when I try to bind the height and width of a window to properties in my view model. Here is a small sample app to illustrate the problem. This is the code in app.xaml.xs</p>
  
  <pre><code>public partial class App : Application
  {
      protected override void OnStartup(StartupEventArgs e)
      {
         base.OnStartup(e);
          MainWindow mainWindow = new MainWindow();
          MainWindowViewModel mainWindowViewModel = new MainWindowViewModel();
          mainWindow.DataContext = mainWindowViewModel;
          mainWindow.Show();
      }
  }
  </code></pre>
  
  <p>This is MainWindow.xaml:</p>
  
  <pre><code>&lt;Window x:Class="TestApp.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Height="{Binding WindowHeight}" 
          Width="{Binding WindowWidth}"
          BorderThickness="{Binding WindowBorderThickness}"&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>And this is the view model:</p>
  
  <pre><code>public class MainWindowViewModel
  {
      public int WindowWidth { get { return 100; } }
      public int WindowHeight { get { return 200; } }
      public int WindowBorderThickness { get { return 8; } }
  }
  </code></pre>
  
  <p>When the program is started the getters of WindowHeight and WindowBorderThickness (but not WindowWidth) are called, so the height and the border of the window is set properly, but not the width.</p>
  
  <p>I then add button that will trigger PropertyChanged for all properties, so that the view model now looks like this:</p>
  
  <pre><code>public class MainWindowViewModel : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
  
      public void TriggerPropertyChanges()
      {
          if (PropertyChanged != null)
          {
              PropertyChanged(this, new PropertyChangedEventArgs("WindowWidth"));
              PropertyChanged(this, new PropertyChangedEventArgs("WindowHeight"));
              PropertyChanged(this, new PropertyChangedEventArgs("WindowBorderThickness"));
          }
  
      }
  
      public ICommand ButtonCommand { get { return new RelayCommand(delegate { TriggerPropertyChanges(); }); } }
  
      public int WindowWidth { get { return 100; } }
      public int WindowHeight { get { return 200; } }
      public int WindowBorderThickness { get { return 8; } }
  }
  </code></pre>
  
  <p>Now, when I click the button, the getter of WindowBorderThickness is called, but not the ones for WindowWidth and WindowHeight. It all just seems very weird and inconsistent to me. What am I missing?</p>