RollOverBubbling
Introduction
Code Example - Scrolling with Cursor Press
// This will work with any item that has a scrollbar, such as
// ListBox, ItemsControl, and ScrollViewer
listBox.Visual.RollOverBubbling += (sender, args) =>
{
var cursor = FormsUtilities.Cursor;
// Only handle this if the crusor is pressed
if (cursor.PrimaryDown)
{
// we can get the vertical scroll bar through visuals:
var scrollBarVisual = (InteractiveGue) listBox.Visual.GetChildByNameRecursively(
ListBox.VerticalScrollBarInstanceName);
// InteractiveGues provide a FormsControlAsObject property to access
// the forms object.
var scrollBar = (ScrollBar)scrollBarVisual.FormsControlAsObject;
// Change the ScrollBar's value which results in the ListBox scrolling.
scrollBar.Value -= cursor.YChange /
global::RenderingLibrary.SystemManagers.Default.Renderer.Camera.Zoom;
// set the Handled property true so children do not get this
args.Handled = true;
}
};

Last updated
Was this helpful?

