【发布时间】:2015-02-16 19:03:17
【问题描述】:
在一个带有 6 个扩展器的网格内有大约 6 个内容控件(每个内容控件在一个扩展器中) 在我的主窗口上,它调用各种用户控件来填充每个上部选项卡/左侧菜单选择的主窗口。
一个扩展器将一次处于活动状态,其余的将被折叠。
每个新窗口都在一个内容控件上。
问题是当我有更大的数据动态加载时,我的内容超出了父控件并且 即使我使用 scrollviewer 时,scrollviewer 也会显示但数据被切断。
这是我的代码: 以下是我在主窗口内容控件中使用的 UserControl 中的代码
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Expander Header="Settings" BorderBrush="SteelBlue" BorderThickness="5"
IsExpanded="{Binding Path=ShowPreview, Mode=TwoWay}"
Background="AliceBlue" FontFamily="Poor Richard" FontSize="24"
FontWeight="Bold">
<DatePicker Name="MyDateRange" />
</Expander>
<Expander Header="Permissions" Grid.Row="1" BorderBrush="SteelBlue"
BorderThickness="5" Background="AliceBlue" FontFamily="Poor Richard"
<local:Permissions />
<!--/*Permissions is another usercontrol with a grid layout (a dataentry form)*/-->
</Expander>
</Grid>
有 6 行的第二个网格是我的 MainWindow 中的代码。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Expander Grid.Row="1" IsExpanded="False" x:Name="Expander1"
Style="{DynamicResource OutlookStyleExpanderStyle}" Visibility="Hidden">
<Expander.Header>
<WrapPanel HorizontalAlignment="Right" Margin="450,0,0,0">
<Button Name="ExpandButtonMin" Background="#FFACD0EE"
Click="ExpandButtonMin_Click" HorizontalAlignment="Right">
<Image Source="/Images/Minimize_Box_Blue.png" Height="30" Width="30" />
</Button>
<Button Name="ExpandButtonMax" Background="#FFACD0EE"
Click="ExpandButtonMax_Click" HorizontalAlignment="Right">
<Image Source="/Images/maximize.png" Height="30" Width="30" />
</Button>
<Button Name="ExpandButtonClose" Background="#FFACD0EE"
Click="ExpandButton1_Click" HorizontalAlignment="Right">
<Image Source="/Images/Close_Box_Red.png" Height="30" Width="30" />
</Button>
</WrapPanel>
</Expander.Header>
<ScrollViewer MaxHeight="800">
<ContentControl Grid.Row="1" x:Name="contentControl1"
Content="{Binding ContentControlOne}" Margin="0,0,0,0"
ScrollViewer.VerticalScrollBarVisibility="Auto" />
</ScrollViewer>
</Expander>
</Grid>
同样有五个扩展行,每个行都有 contentcontrol2,..。
问题是当我的内容控件的最大动态内容超过父大小时,数据被切断并且滚动查看器显示但仍不显示完整数据。当我删除滚动查看器高度并将滚动查看器高度保持为“自动”时,滚动查看器根本不显示。
【问题讨论】:
-
你能分享你的代码吗?
标签: wpf scrollviewer