我的项目中有一个ItemsControl,如果有多个无法容纳在视图中的项目,则应该可以滚动。我用ItemsControl
包装了ScrollViewer
,但它只显示了不起作用的滚动条。为什么自从我定义了ItemTemplate
以来,默认情况下ItemControl的项就无法滚动。
这是我的XAML
<Border Style="{StaticResource styleUpdatesContentBorder}">
<ItemsControl x:Name="updateDownloadStatus" ItemsSource="{Binding LatestUpdates}">
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer x:Name="ScrollViewer" Style="{StaticResource QSFScrollViewerStyle}" VerticalScrollBarVisibility="Auto" Padding="{TemplateBinding Padding}">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Control.Margin" Value="5"/>
<Style.Triggers>
<Trigger Property="Control.IsMouseOver" Value="True">
<Setter Property="Control.ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=Content.FileName}"/>
</Trigger>
</Style.Triggers>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="#01FFFFFF" BorderBrush="DarkGray" BorderThickness="1" CornerRadius="3" >
<Grid Margin="5,5,5,5">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding Activity}" Style="{StaticResource styleLatestProductUpdates}" />
<TextBlock Grid.Row="1" Text="{Binding FileName}" Style="{StaticResource styleLatestProductUpdates}"/>
<TextBlock Grid.Row="2" Text="{Binding Size}" Style="{StaticResource styleLatestProductUpdates}" />
<telerik:RadProgressBar Name="downloadProgress" Grid.Row="3"
HorizontalAlignment="Center" Width="265"
Foreground="Goldenrod" />
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>