I made a simple custom control to contain some parameter, and put all of these controls in a ItemsControl like this.
I have tried all my mind to stretch the items for filling all remaining space, but VerticalContentAlignment do not work right , containing the items in a UniformGrid either.
There's nothing but a simple control for displaying, but i got many of them in my project, i don't want to use to many RowDefinition Is there a simple way to do the stretch thing?
<Grid Background="{StaticResource BackgroundLightBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<!-- Title -->
<Grid Height="56">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<TextBlock
Margin="20,15"
VerticalAlignment="Center"
FontSize="{StaticResource FontForTitle}"
Text="{Binding Title}" />
<Button
Grid.Column="2"
Width="{Binding ActualHeight, RelativeSource={RelativeSource self}}"
Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=StackPanel}}"
Margin="7"
Style="{StaticResource MenuButton}"
Visibility="{Binding ButtonVisibility, Converter={local:BooleanToVisibilityConverter}}" />
</Grid>
<!-- Status Bars -->
<Border
Grid.Row="1"
Height="{Binding StatusBarsHeight}"
Background="{Binding Status,Converter={local:LightGrayToGreenByBooleanConverter}}"
/>
<!-- Parameter -->
<ItemsControl Grid.Row="2" ItemsSource="{Binding Items}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:DisplayLabel />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
Try:
<ItemsControl Grid.Row="2" ItemsSource="{Binding Items}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:DisplayLabel />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="1"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>