ItemsControl
Horizo ntal StackPanel
as ItemsPanel
(基本的にある種の WinRT Hub コントロール)を含む WPF UserControl があります。そして、コンテンツは 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 を介して注入されます。
EDIT1:
がメインUserControl
フォームに注入されています。ContrentControl
=> ShellRegions.Content (3 番目のもの)に割り当てられます。
<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
UserControl
ItemsControl
ScrollBar
ScrollViewer
UserControll
ScrollBar
しかし、スケーリングを維持し、スクロールバーを の下部に追加することはできませんItemsControl
。