ScrollableBase
ScrollableBase is a common component that supports scrolling. You can add several views to the ScrollableBase component. You can use a mouse or finger on the touch screen to drag a ScrollableBase component.
Create with property
To create a ScrollableBase using various properties, follow these steps:
-
Create
ScrollableBase
using the default constructor:C#CopyScrollableBase scrollableBase = new ScrollableBase();
-
Set the
ScrollableBase
property:C#CopyscrollableBase.Size = new Size(400, 300); scrollableBase.ScrollingDirection = ScrollableBase.Direction.Vertical; Window.Instance.GetDefaultLayer().Add(scrollableBase);
-
Add child views for
ScrollableBase
:C#CopyView[] items = new View[5]; for (int i = 0; i < items.Length; i++) { items[i] = new View { Position = new Position(0, i * 100), Size = new Size(400, 100), }; if (i % 2 == 0) { items[i].BackgroundColor = Color.Magenta; } else { items[i].BackgroundColor = Color.Cyan; } scrollableBase.Add(items[i]); }
Following output is generated when the ScrollableBase is created using property:
Scroll drag events responses
When a ScrollableBase is dragged, the ScrollableBase instance receives a scroll drag start event. When the ScrollBase dragging is stopped, the ScrollableBase instance receives a scroll drag ended event. You can declare the events handlers as follows:
C#
Copy
ScrollableBase scrollableBase = new ScrollableBase();
scrollableBase.ScrollDragStarted += ScrollDragStarted;
scrollableBase.ScrollDragEnded += ScrollDragEnded;
C#
Copy
private void ScrollDragStarted(object sender, ScrollEventArgs e)
{
// Do something in response to scroll drag started
}
private void ScrollDragEnded(object sender, ScrollEventArgs e)
{
// Do something in response to scroll drag ended
}
The following output is generated when the ScrollableBase is dragged:
Related information
- Dependencies
- Tizen 6.0 and Higher