Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DispatcherTimer timer = new DispatcherTimer();
- double current = 0;
- // Constructor
- public MainPage()
- {
- InitializeComponent();
- timer = new DispatcherTimer();
- this.imagesScrollview.Loaded += new RoutedEventHandler(imagesScrollview_Loaded);
- timer.Interval = TimeSpan.FromSeconds(1);
- timer.Tick += new EventHandler(timer_Tick);
- timer.Start();
- }
- void timer_Tick(object sender, EventArgs e)
- {
- // ScrollViewer sv = new ScrollViewer();
- imagesScrollview.InvalidateScrollInfo();
- imagesScrollview.ScrollToHorizontalOffset(current);
- imagesScrollview.UpdateLayout();
- current = current + 100;
- textBlock2.Text = current.ToString();
- }
- <ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="8,563,8,2" Width="auto" x:Name="imagesScrollview" Opacity="1" Background="#FF3ED216" Grid.Row="1" RenderTransformOrigin="0.5,0.5" Loaded="imagesScrollview_Loaded">
- <ScrollViewer.RenderTransform>
- <CompositeTransform/>
- </ScrollViewer.RenderTransform>
- <ListBox x:Name="listBox" Width="Auto" Height="Auto" Background="#FF3ED216" ManipulationCompleted="listBox_ManipulationCompleted">
- <ListBox.RenderTransform>
- <CompositeTransform/>
- </ListBox.RenderTransform>
- <ListBox.ItemsPanel>
- <ItemsPanelTemplate>
- <StackPanel Orientation="Horizontal">
- <StackPanel.RenderTransform>
- <TranslateTransform X="0" />
- </StackPanel.RenderTransform>
- </StackPanel>
- </ItemsPanelTemplate>
- </ListBox.ItemsPanel>
- <ListBox.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal" Margin="15,0">
- <Image x:Name="imageAV" Source="{Binding avlink}" Height="80" Width="80" Stretch="UniformToFill" MouseLeftButtonUp="imageAV_MouseLeftButtonUp" ImageFailed="imageAV_ImageFailed" />
- <StackPanel Orientation="Vertical" Margin="10,0,0,0" MouseLeftButtonUp="StackPanel_MouseLeftButtonUp">
- <TextBlock Text="{Binding nickname}" Width="120"/>
- <TextBlock Text="{Binding track}" FontWeight="Bold" Width="120"/>
- <TextBlock Text="{Binding artist}" Width="120"/>
- </StackPanel>
- </StackPanel>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- </ScrollViewer>
- var dt = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
- dt.Tick += (s, args) =>
- {
- var count = VisualTreeHelper.GetChildrenCount(this.MainListBox);
- for (var idx = 0; idx < count; idx++)
- {
- var child = VisualTreeHelper.GetChild(this.MainListBox, idx);
- if (child is ScrollViewer)
- {
- var sv = child as ScrollViewer;
- sv.ScrollToVerticalOffset(sv.VerticalOffset + 1);
- break;
- }
- }
- };
- dt.Start();
- <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled"
Add Comment
Please, Sign In to add comment