title: Getting window height from in a view model
body: <p>I am trying to find a way to access the window height of my screen from my view model, so that I can set my MaxHeight to be a percentage of the window height.</p>
  
  <p><strong>XAML</strong></p>
  
  <pre><code>&lt;UserControl&gt;
      &lt;i:Interaction.Triggers&gt;
          &lt;i:EventTrigger EventName="SizeChanged"&gt;
              &lt;i:InvokeCommandAction Command="{Binding SizeChangedCommand}" /&gt;
          &lt;/i:EventTrigger&gt;
      &lt;/i:Interaction.Triggers&gt;
  &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="*" /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto" /&gt;
              &lt;RowDefinition Height="Auto" /&gt;
      &lt;Grid.RowDefinitions/&gt;
      &lt;ListBox Grid.Row="0"
               Content={Binding SomeContent}
               MaxHeightMaxHeight="{Binding PercentageMaxHeight}"/&gt;
      &lt;Button Content="ClickMe"
              Grid.Row="1" /&gt;
  &lt;/Grid&gt;
  &lt;UserControl/&gt;
  
  </code></pre>
  
  <p>To be clear, this is not my actual complete XAML. The idea is that I want my ListBox to have a maximum height that is a percentage of the screen size so that my button is always right below my listbox, but the listbox does not push the button off the screen when it's too filled up. </p>
  
  <p><strong>View Model</strong></p>
  
  <pre><code>public PercentageMaxHeight;
  public ICommand SizeChangedCommand =&gt; new RelayCommand(SizeChangedCommandExecuted);
  
  private void SizeChangedCommandExecuted()
  {
      /*I am looking for a way to access ActualHeight, or any other way of getting the height of my window 
      here, so I can update PercentageMaxHeight. */
  }
  
  </code></pre>
  
  <p>I don't want to set it from the code behind my XAML, because I am trying to follow MVVM. </p>