Everything regarding my layout will be current with the resizing of the main window. The problem I am facing is that, as you can see, the datagrid is disconnecting from the screen. If you maximize the window, the datagrid will resize using the window, but continue to exit the screen. How do I get it to keep its margin at 20 using the parent grid?
<Grid> <StackPanel Orientation="Vertical"> <TextBox Height="170" Name="txtSQL" VerticalAlignment="Top" AcceptsReturn="True" TextWrapping="Wrap" Margin="20"/> <Button Content="Run!" Height="23" HorizontalAlignment="Left" Name="btnRun" VerticalAlignment="Top" Margin="20,0,0,0" Width="75" Click="btnRun_Click" /> <Grid> <my:DataGrid Name="dgResults" VerticalAlignment="Top" Margin="20" /> </Grid> </StackPanel> </Grid>

UPDATE: Just to be more specific. The effect I'm trying to accomplish is this:
When the window first loads, you are given an empty datagrid, so it only has about 15 pixels. When you run the query, it will populate the datagrid, reassigning the itemssource. At the moment, when you do this, if the data exceeds the size of the window, it will disappear at the bottom of the screen. I need it to only expand to the bottom of the window and then activate the scroll bar. I can do this by simply wrapping it in a scrollviewer. However, when the window size changes, the datagrid needs to be resized.
I am wondering if this setup can have anything to do with this. The form is a wpf page displayed in the frame.
UPDATE:
<Page x:Class="Hold_Database___Prototype_1.Views.SQL" 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="304" d:DesignWidth="732" Title="SQL" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" AllowDrop="True"> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="23" /> <RowDefinition Height="*"/> </Grid.RowDefinitions> <TextBox Height="170" Name="txtSQL" VerticalAlignment="Top" AcceptsReturn="True" TextWrapping="Wrap" Margin="20" Grid.Row="0"/> <Button Content="Run!" Height="23" HorizontalAlignment="Left" Name="btnRun" VerticalAlignment="Top" Margin="20,0,0,0" Width="75" Grid.Row="1" Click="btnRun_Click" /> <DockPanel Grid.Row="2"> <my:DataGrid Name="dgResults" Margin="20" /> </DockPanel> </Grid> </Page>
source share