因为子控件是一个滚动查看器,所以我不能使用堆栈面板,因为它倾向于超出父容器约束。
我有一个包含多行的网格,其中一个中心行需要折叠,当不包含很多但仍然展开到*
(剩余的可用空间)时,该行有一个滚动内部的查看器将处理超过该点的溢出。
<DataTemplate DataType="{x:Type IMPI:SettingGroup}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Content="{Binding Name}" Grid.Row="0"/>
<TextBlock Grid.Row="1" Text="{Binding Description}"/>
<!-- I want this row to shrink when its size is less than the remaining space determined by "*" -->
<TabControl Grid.Row="2" ItemsSource="{Binding Groups}" Visibility="{Binding Groups, Converter={StaticResource VisibleIfItemsPresent}}">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<ScrollViewer>
<ContentPresenter Content="{Binding}"/>
</ScrollViewer>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
<ItemsControl Grid.Row="3" ItemsSource="{Binding Settings}" Visibility="{Binding Settings, Converter={StaticResource VisibleIfItemsPresent}}"/>
</Grid>
</DataTemplate>