Guest User

Untitled

a guest
Jul 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. DispatcherTimer timer = new DispatcherTimer();
  2. double current = 0;
  3. // Constructor
  4. public MainPage()
  5. {
  6. InitializeComponent();
  7. timer = new DispatcherTimer();
  8. this.imagesScrollview.Loaded += new RoutedEventHandler(imagesScrollview_Loaded);
  9. timer.Interval = TimeSpan.FromSeconds(1);
  10.  
  11. timer.Tick += new EventHandler(timer_Tick);
  12. timer.Start();
  13. }
  14. void timer_Tick(object sender, EventArgs e)
  15. {
  16. // ScrollViewer sv = new ScrollViewer();
  17. imagesScrollview.InvalidateScrollInfo();
  18. imagesScrollview.ScrollToHorizontalOffset(current);
  19. imagesScrollview.UpdateLayout();
  20. current = current + 100;
  21. textBlock2.Text = current.ToString();
  22.  
  23. }
  24.  
  25. <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">
  26. <ScrollViewer.RenderTransform>
  27. <CompositeTransform/>
  28. </ScrollViewer.RenderTransform>
  29. <ListBox x:Name="listBox" Width="Auto" Height="Auto" Background="#FF3ED216" ManipulationCompleted="listBox_ManipulationCompleted">
  30. <ListBox.RenderTransform>
  31. <CompositeTransform/>
  32. </ListBox.RenderTransform>
  33. <ListBox.ItemsPanel>
  34. <ItemsPanelTemplate>
  35. <StackPanel Orientation="Horizontal">
  36. <StackPanel.RenderTransform>
  37. <TranslateTransform X="0" />
  38. </StackPanel.RenderTransform>
  39. </StackPanel>
  40. </ItemsPanelTemplate>
  41. </ListBox.ItemsPanel>
  42. <ListBox.ItemTemplate>
  43. <DataTemplate>
  44. <StackPanel Orientation="Horizontal" Margin="15,0">
  45. <Image x:Name="imageAV" Source="{Binding avlink}" Height="80" Width="80" Stretch="UniformToFill" MouseLeftButtonUp="imageAV_MouseLeftButtonUp" ImageFailed="imageAV_ImageFailed" />
  46. <StackPanel Orientation="Vertical" Margin="10,0,0,0" MouseLeftButtonUp="StackPanel_MouseLeftButtonUp">
  47. <TextBlock Text="{Binding nickname}" Width="120"/>
  48. <TextBlock Text="{Binding track}" FontWeight="Bold" Width="120"/>
  49. <TextBlock Text="{Binding artist}" Width="120"/>
  50. </StackPanel>
  51. </StackPanel>
  52. </DataTemplate>
  53. </ListBox.ItemTemplate>
  54. </ListBox>
  55. </ScrollViewer>
  56.  
  57. var dt = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
  58. dt.Tick += (s, args) =>
  59. {
  60. var count = VisualTreeHelper.GetChildrenCount(this.MainListBox);
  61.  
  62. for (var idx = 0; idx < count; idx++)
  63. {
  64. var child = VisualTreeHelper.GetChild(this.MainListBox, idx);
  65.  
  66. if (child is ScrollViewer)
  67. {
  68. var sv = child as ScrollViewer;
  69.  
  70. sv.ScrollToVerticalOffset(sv.VerticalOffset + 1);
  71.  
  72. break;
  73. }
  74. }
  75. };
  76. dt.Start();
  77.  
  78. <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled"
Add Comment
Please, Sign In to add comment