Hi,@vitaminchik. Welcome to Microsoft Q&A.
Reason: <Grid> incorrect usage.
<Grid> needs to define how many rows and columns it has, and needs to specify the row and column of the element through Grid.Row and Grid.Column like DockPanel.Dock="Left". By default, the Grid has 0 rows and 0 columns. When the element does not specify Grid.Row and Grid.Column, the default is Grid.Row=0 and Grid.Column=0. So you will see overlap.
Solution:You could refer to the following code to modify.
<StackPanel Style="{DynamicResource StyleOfStackPanel}" >
<TextBlock Text="Buy" HorizontalAlignment="Center" />
<Border Style="{DynamicResource StyleOfBorder}">
<Grid Height="300" >
<!--Set the height in advance so that you could divide the height of different rows later-->
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="11*"></RowDefinition>
<!--Divide the row height between two rows in a ratio of 1:13. You could also specify a specific value to divide.-->
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" Height="25" VerticalAlignment="Top">
<TextBlock Text="Date" Margin="50 0 0 0" Padding="0 0 10 0" VerticalAlignment="Center"/>
<TextBox x:Name="textBoxOfDate" Width="100" Height="17" />
</StackPanel>
<ItemsControl Grid.Row="1" x:Name="itemsControlOfPurchase" Margin="0,30,0,0" HorizontalAlignment="Center">
<!--Center the ItemsControl horizontally here-->
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,30">
<!--Use Margin here to keep each Item separated-->
<Border BorderBrush="Green" BorderThickness="1">
<!--The border color is drawn with BorderBrush, and the border width is drawn with BorderThickness.-->
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<!--Divide column width by 1:1-->
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<!--Divide row height by 1:1:1:1-->
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding NameOfProduct}" Padding="0 0 10 0" Width="100" Margin="3" />
<TextBox Grid.Row="0" Grid.Column="1" x:Name="textBoxOfQuantity" IsReadOnly="False" Padding="0 0 10 0" Width="100" Margin="3"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="pc." Padding="0 0 10 0" Width="100" Margin="3"/>
<TextBlock Grid.Row="1" Grid.Column="1" Text="price" Padding="0 0 10 0" Width="100" Margin="3"/>
<TextBox Grid.Row="2" Grid.Column="0" x:Name="textBoxOfPrice" IsReadOnly="False" Padding="0 0 10 0" Width="100" Margin="3"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="$. total." Width="100" Margin="3"/>
<TextBox Grid.Row="3" Grid.ColumnSpan="2" x:Name="textBoxOfTotalPrice" Width="150" Margin="3"/>
<!--Grid.ColumnSpan="2" combines the two columns of the current row into one column.-->
</Grid>
</Border>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Border>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="reset" Width="135" Background="LightPink" />
<Button Content="Save" Width="135" Background="GreenYellow" />
</StackPanel>
</StackPanel>
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.