Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>An other way to do this (very basic example):<br /> xaml:<br /></p> <pre><code>&lt;Grid x:Name="LayoutRoot"&gt; &lt;data:DataGrid x:Name="dg" Height="100"&gt; &lt;ScrollViewer.VerticalScrollBarVisibility&gt;true&lt;/ScrollViewer.VerticalScrollBarVisibility&gt; &lt;/data:DataGrid&gt; </code></pre> <p></p> <p><br /> CS:<br /></p> <pre><code>public partial class MainPage : UserControl { IList&lt;Person&gt; list = new List&lt;Person&gt;(); public MainPage() { InitializeComponent(); list.Add(new Person("Pieter1","Nijs")); list.Add(new Person("Pieter2", "Nijs")); list.Add(new Person("Pieter3", "Nijs")); list.Add(new Person("Pieter4", "Nijs")); list.Add(new Person("Pieter5", "Nijs")); list.Add(new Person("Pieter6", "Nijs")); list.Add(new Person("Pieter7", "Nijs")); list.Add(new Person("Pieter8", "Nijs")); dg.ItemsSource = list; dg.MouseWheel += new MouseWheelEventHandler(dg_MouseWheel); } void dg_MouseWheel(object sender, MouseWheelEventArgs e) { if (e.Delta &lt; 0) { dg.ScrollIntoView(list[dg.SelectedIndex + 2], null); } else { dg.ScrollIntoView(list[dg.SelectedIndex - 2], null); } } } </code></pre> <p>So, what I do here is quite simple!<br /> I add an EventHandler to the <code>DataGrid MouseWheel</code> - event. In that handler I retreive the <code>e.Delta</code> (this is the amount the wheel has changed since the last time) so I know if the user scrolled up (positive Delta) or down (negative Delta). And then I call the <code>ScrollIntoView</code>-method of the DataGrid, where I can specify to what row the Grid should scroll to. <br /> As mentioned, this is a very basic example! This is just to show you how it could work! You should add extra logic to make sure you don't go out of bounce!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload