2012-11-07 48 views
0
<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的高度屬性。我仍然看不到任何滾動條ScrollViewer與ItemsControl不起作用

+0

嗨,你能定義一下「不工作」嗎?我不清楚你遇到什麼問題 – Rachel

+0

ScrollViewer不顯示。無論我在哪裏放置滾動查看器,它都不會顯示 –

+0

您是否將ScrollViewer設置爲高度,或將其限制在限制其子項大小的面板內?如果高度不受某些限制,ScrollViewer沒有理由顯示滾動條,因爲它可以增長到所需的任何高度。你可以通過設置'VerticalSCrollBarVisibility'和'Horizo​​ntalScrollBarVisibility'爲'Visible'來測試它,以確保它們總是顯示出來。 – Rachel

回答

2

你給你的ScrollViewer一個高度,或限制在一個限制其子女的高度的面板?

如果高度不受某些限制,ScrollViewer沒有理由顯示滾動條,因爲它可以增長到需要顯示其子級的任何高度。

您可以通過設置VerticalScrollBarVisibilityHorizontalScrollBarVisibilityVisible測試,看看你的ScrollViewer實際上是,如果是這樣的話,那麼你可以通過塞汀的ScrollViewer.Height解決該問題的一個值,或在其包裝容器不允許孩子長到他們想要的大小。

0

您必須爲ItemsPresenter定義ControlTemplate,其中包含ScrollViewer。我不相信它包括默認的一個...

相關問題