Why does this WPF window does not auto-sets its width and height, depending of the Grid or listbox size (so depending of the number of items into the listbox)?:
<controls:MetroWindow x:Class="....."
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
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"
Width="Auto" Height="Auto" MaxHeight="500" MaxWidth="500">
<Grid Background="Gray" Width="Auto" Height="Auto" >
<ListBox Width="Auto" Height="Auto" FontSize="12" FontWeight="SemiBold" ItemsSource="{Binding ListError}" >
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</controls:MetroWindow>
In this case, it renders 500*500 ( = my MaxWidth and MaxHeight values). If I remove the MaxWidth and MaxHeight values, it till does not auto-fit to the listbox size.
Thx in advance.