2011-04-11 41 views
0

我有一个Silverlight应用程序需要在应用程序的页脚上滚动一些数据(如股票信息)。在努力做到这一点,我创建了以下内容:在Silverlight中创建滚动项目

<UserControl.Resources> 
    <Storyboard x:Name="myListStoryboard" BeginTime="0:0:0" Completed="myListStoryboard_Completed"> 
     <DoubleAnimation x:Name="myListAnimation" Duration="0:0:30" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="myItemsControl" /> 
    </Storyboard> 
</UserControl.Resources> 


<Border x:Name="infoListBorder" Grid.Row="1" Height="40" HorizontalAlignment="Stretch" BorderThickness="1,1,0,0" Background="Silver"> 
    <Grid> 
    <ItemsControl x:Name="myItemsControl" HorizontalAlignment="Right" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"> 
     <ItemsControl.ItemsPanel> 
     <ItemsPanelTemplate> 
      <StackPanel Orientation="Horizontal"></StackPanel> 
     </ItemsPanelTemplate>       
     </ItemsControl.ItemsPanel> 
     <ItemsControl.RenderTransform> 
     <CompositeTransform/> 
     </ItemsControl.RenderTransform> 
    </ItemsControl> 
    </Grid> 
</Border> 

我在我的代码绑定字符串元素myItemsControl的名单后面。这些元素将会是对象,我想在我的ItemsControl中使用DataTemplate。现在,我只是试图让文本显示出来。我的问题是,并非所有的项目都显示正确。它看起来好像最后一个被切断了。我怀疑它是因为Items控件中的UIVirtualization,但我不知道如何解决这个问题。

我在做什么错?我如何让我的所有物品都能出现?

你好!

回答

1

尝试以下

<Border x:Name="infoListBorder" Grid.Row="1" Height="40" HorizontalAlignment="Stretch"      BorderThickness="1,1,0,0" Background="Silver"> 
    <Grid> 
    <ScrollViewer> 
     <ItemsControl x:Name="myItemsControl" HorizontalAlignment="Right" > 
      <ItemsControl.ItemsPanel> 
      <ItemsPanelTemplate> 
       <StackPanel Orientation="Horizontal"></StackPanel> 
      </ItemsPanelTemplate>       
      </ItemsControl.ItemsPanel> 
      <ItemsControl.RenderTransform> 
      <CompositeTransform/> 
      </ItemsControl.RenderTransform> 
     </ItemsControl> 
    </ScrollViewer> 
    </Grid> 
</Border> 

的ItemsControl没有预设模板的ScrollViewer(DataGrid中,组合框,列表框)。 你也可以编辑样式并将ScrollViwer放入样式 (ScrollViwer内的ItemsPrensenter)