1
<ScrollViewer VerticalScrollBarVisibility="Visible"  Height="100">
        <ItemsControl Name="icReviews" BorderBrush="Black" BorderThickness="1" Height="300">
            <ItemsControl.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
                    <GradientStop Offset="1" Color="#FFFF9900" />
                    <GradientStop Offset="0" Color="#FFDD4400" />
                </LinearGradientBrush>
            </ItemsControl.Background>

            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="3" Width="1712" Height="300"></UniformGrid>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>


            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition ></RowDefinition>
                                <RowDefinition></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <StackPanel Grid.Row="0" Grid.Column="1" TextElement.FontFamily="FangSong" TextElement.FontSize="15"  TextElement.FontWeight="Bold" TextElement.Foreground="Blue">
                                <TextBlock Text="{Binding Path=Subject}" Foreground="White" TextElement.FontSize="15" TextElement.FontFamily="FangSong" TextWrapping="Wrap" Margin="5,5"></TextBlock>
                                <TextBlock Text="{Binding Path=Review}" Foreground="White" TextElement.FontSize="15" TextElement.FontFamily="FangSong" TextWrapping="Wrap" Margin="5,5"></TextBlock>
                                <WrapPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="Posted by : " Foreground="White" Margin="5,5" TextElement.FontSize="15"></TextBlock>
                                        <TextBlock Text="{Binding Path=Username}" Foreground="White" TextElement.FontSize="15" TextElement.FontFamily="FangSong" Margin="5,5"></TextBlock>
                                    </StackPanel>
                                </WrapPanel>
                            </StackPanel>
                        </Grid>
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>

        </ItemsControl>
    </ScrollViewer>

これで、scrollviewerのheight属性を使用してコードを編集しました。まだスクロールバーが表示されません

4

2 に答える 2

5

あなたはあなたScrollViewerの身長を与えていますか、それともその子供たちの身長を制限するパネル内にそれを拘束していますか?

高さが何らかの方法で制限されていない場合はScrollViewer、子を表示するために必要な高さに成長できるため、スクロールバーを表示する理由はありません。

VerticalScrollBarVisibilityHorizontalScrollBarVisibilityを設定しVisibleて実際の場所を確認することでテストできますScrollViewer。その場合は、ScrollViewer.Heightを値に設定するか、子を成長させないコンテナにラップすることで問題を修正できます。彼らが望むどんなサイズにも。

于 2012-11-07T19:10:55.953 に答える
0

を含むControlTemplateforを定義する必要があります。デフォルトで含まれているとは思わない...ItemsPresenterScrollViewer

于 2012-11-07T16:19:09.377 に答える