【发布时间】:2019-04-05 02:36:10
【问题描述】:
我的用户控件中有一个ItemsControl,当它变得太大时,它周围有一个滚动查看器(太大的内容大于UserControl 的可视区域)。问题是它所在的网格一直在扩展,因此滚动查看器永远不会启动(除非我为网格指定了确切的高度)。请参阅下面的代码并提前致谢。
<UserControl x:Class="BusinessObjectCreationWizard.View.TableSelectionPageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<GroupBox FontWeight="Bold" Height="300px"
Header="Tables"
Padding="2">
<ScrollViewer>
<ItemsControl FontWeight="Normal"
ItemsSource="{Binding Path=AvailableTables}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Path=DisplayName}"
IsChecked="{Binding Path=IsSelected}"
Margin="2,3.5" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</GroupBox>
</UserControl>
这里加载了这个用户控件
<Border Background="White" Grid.Column="1" Grid.Row="0">
<HeaderedContentControl Content="{Binding Path=CurrentPage}"
Header="{Binding Path=CurrentPage.DisplayName}" />
</Border>
我不想指定高度。
【问题讨论】:
-
Grid 的扩展取决于它所包含的内容。您需要显示更多的 XAML 以获得准确的答案。
-
我添加了额外的代码(虽然格式很奇怪)