Q:

WPF margins don't add up

I just started working with WPF and I am trying to set up a grid with four rows that have a height of 150. That would take up 600 of my 800 pixels that I set for the height. I then set my top margin to 30 and my bottom margin to 170  to give myself some room for controls at the bottom.
Everything looks great in design view but when I run my applications the bottom row has some area cut off.
Design View

Running View

I don't understand what is causing this discrepancy between these views.
 <Page x:Class="EzTargetProject.HomePage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  mc:Ignorable="d" 
  d:DesignHeight="800" d:DesignWidth="1280"
Title="HomePage">

<Grid  Margin="20,30,20, 170" Grid.Column="4" Grid.Row="4" Background="Gray" ShowGridLines="True">
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="150"/>
        <RowDefinition Height="150"/>
        <RowDefinition Height="150"/>
        <RowDefinition Height="150"/>
    </Grid.RowDefinitions>

    <!-- Name -->
    <StackPanel Grid.Column="0" Grid.Row="0" Orientation="Vertical" />
</Grid>

A:

You can avoid the bottom margin if you want to set the height of your grid.
If you always want to have a 600px height grid, just set it.
I'd use a ScrollViewer as a parent to let the user see the controls you are going to set under the grid (if the user wants to have a little window forexample):
Enabling Scrollbar in WPF

