facing problem in aalignment of stack panel
<Window x:Class="SlidingChart.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:ref="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:annonation="clr-namespace:System.ComponentModel.DataAnnotations.Schema;assembly=System.ComponentModel.DataAnnotations"
Title="MainWindow" Height="436" Width="700" Loaded="Window_Loaded_1">
<Grid>
<StackPanel Margin="0,0,196,0">
<charting:Chart Name="parentchart" Height="393" Loaded="parentchart_Loaded">
<charting:Chart.Axes>
<charting:LinearAxis Orientation="X" x:Name="orty" Maximum="{Binding Path=Text, ElementName=txtx,Mode=TwoWay}" Title="Ledmodule operating (mA)" ShowGridLines="True">
</charting:LinearAxis>
<!--<charting:LinearAxis Name="ycordinate" Orientation="Y" Maximum="{Binding Path=Text, ElementName=txty, Mode=TwoWay}" Title="operating Current(mA)" Interval="40" ShowGridLines="True"></charting:LinearAxis>-->
</charting:Chart.Axes>
<charting:LineSeries Name="charts" ItemsSource="{Binding UpdateSourceTrigger=PropertyChanged}" DependentValuePath="Value" IndependentValuePath="Key" IsSelectionEnabled="True" >
</charting:LineSeries>
</charting:Chart>
</StackPanel>
<StackPanel HorizontalAlignment="Left">
<GroupBox Header="do changes here" Margin="501,20,0,0" VerticalAlignment="Top" Height="376" Width="181">
<StackPanel>
<TextBox HorizontalAlignment="Left" Name="txtx" TextWrapping="Wrap" Width="126" Margin="0,0,0,178"></TextBox>
<TextBox Name="txty" VerticalAlignment="Top"></TextBox>
<ListBox Height="23" Name="cmb"></ListBox>
<!--<TextBlock ScrollViewer.VerticalScrollBarVisibility="Visible" TextWrapping="Wrap" Name="cmb" Text="TextBlock"/>-->
<TextBox Height="23" BorderThickness="2" TextWrapping="Wrap" Name="txtxvalue" TextChanged="txtxvalue_TextChanged"/>
<TextBox Height="23" TextWrapping="Wrap" Name="txtyvalue" />
<Button Content="Button" Click="Button_Click_1"/>
</StackPanel>
</GroupBox>
</StackPanel>
</Grid>
</Window>
when i am streching my screen group box is fixed.
when clicking on the maximize button of window they overlap each other