0

ItemsControlHorizo ​​ntal StackPanelas ItemsPanel(基本的にある種の WinRT Hub コントロール)を含む WPF UserControl があります。そして、コンテンツは UserControl のサイズを拡張します

ScrollViewerの周りにを追加しようとするとItemsControlScrollViewerが縮小する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の境界を変更するとコンテンツは期待どおりにスケーリングしますが、は を表示しません。追加すると、コンテンツは境界の変更に合わせてスケーリングされなくなり、水平ではなく垂直にスクロール可能になります。または、プロパティに応じてアイテムの幅が収まるように変更されます。FormUserControlItemsControlScrollBarScrollViewerUserControllScrollBar

しかし、スケーリングを維持し、スクロールバーを の下部に追加することはできませんItemsControl

4

2 に答える 2

0

研究でいっぱいの一日の後、私は実用的な解決策を見つけました:

<ItemsControl regions:RegionManager.RegionName="{x:Static statics:ContentRegions.ContentCollection}">
            <ItemsControl.Template>
                <ControlTemplate>
                    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
                        <ItemsPresenter/>
                    </ScrollViewer>
                </ControlTemplate>
            </ItemsControl.Template>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
于 2013-10-30T14:23:27.177 に答える