我有一个 WPF UserControl,其中包含一个ItemsControl
Horizo ntal StackPanel
as ItemsPanel
(基本上是某种 WinRT Hub 控件)。并且内容扩展了 UserControl 的大小
如果我尝试ScrollViewer
在我的 周围添加一个ItemsControl
,则ScrollViewer
缩小ItemsControl
所有项目都适合 UserControl 边界。
这与我的预期完全相反,有人能告诉我为什么滚动查看器会这样吗?
这是我的UserControl
:
<UserControl x:Class="ContentModule.ContentView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
xmlns:contentModule="clr-namespace:ContentModule"
xmlns:regions="http://www.codeplex.com/CompositeWPF"
xmlns:statics="clr-namespace:Infrastructure.Statics;assembly=Infrastructure"
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance contentModule:ContentViewModel}"
VerticalAlignment="Top" HorizontalAlignment="Left">
<ItemsControl regions:RegionManager.RegionName="{x:Static statics:ContentRegions.ContentCollection}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</UserControl>
项目通过 Prism RegionManager 注入。
编辑1:
UserControl
正在被注入到我的 MainForm 中。它分配给ContrentControl
=> ShellRegions.Content(第三个)
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ContentControl Grid.Row="0" cal:RegionManager.RegionName="{x:Static statics:ShellRegions.MainMenu}" />
<ItemsControl Grid.Row="1" cal:RegionManager.RegionName="{x:Static statics:ShellRegions.NavigationBar}" />
<ContentControl Grid.Row="2" cal:RegionManager.RegionName="{x:Static statics:ShellRegions.Content}" />
</Grid>
编辑2:更多细节。
ItemsControl
看起来像:(灰色是UserControl
,橙色是 中的项目)内容按预期ItemsControl
更改Form
/的边界时缩放,但不显示 a 。如果我添加一个内容不再随着边界的变化而缩放,并且可以垂直滚动而不是水平滚动,或者它确实会改变项目的宽度以适应取决于属性。UserControl
ItemsControl
ScrollBar
ScrollViewer
UserControll
ScrollBar
但我无法让它保持缩放并将滚动条添加到ItemsControl
.