Reputation: 11131
I have a Silverlight application that needs to scroll some data (like stock information) across the footer of the application. In an effort to do this, I created the following:
<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>
I am binding a List of string elements to myItemsControl in my code behind. These elements will be objects later and I want to use a DataTemplate in my ItemsControl. For now, I'm just trying to get the text to display. My problem is, not all of the items appear correctly. It looks as if one at the end gets cut off. I suspect that its because of UIVirtualization in an Items control, but I'm not sure how to fix this.
What am I doing wrong? How do I get all of my items to appear?
Thnk you!
Upvotes: 0
Views: 294
Reputation: 551
Try following
<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 not have in default template ScrollViewer(DataGrid,ComboBox,ListBox). Also you can edit style and put ScrollViwer into style (ItemsPrensenter inside ScrollViwer)
Upvotes: 1