2 using System.Collections.Generic;
4 using Tizen.NUI.BaseComponents;
6 namespace Tizen.NUI.Samples
8 public class ScrollableBaseOutOfBoundSample : IExample
11 private Components.ScrollableBase mScrollableBase = null;
12 private TextLabel[] items;
14 public void Activate()
16 Window window = NUIApplication.GetDefaultWindow();
19 Size = new Size(1920, 1080),
20 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
22 root.Layout = new LinearLayout()
24 LinearOrientation = LinearLayout.Orientation.Vertical
28 CreateScrollableBase();
31 private void CreateScrollableBase()
33 mScrollableBase = new Components.ScrollableBase()
35 Position = new Position(300, 100),
36 Size = new Size(400, 300),
37 ScrollingDirection = Components.ScrollableBase.Direction.Vertical,
38 EnableOverShootingEffect = true,
40 mScrollableBase.ScrollOutOfBound += OnScrollOutOfBound;
42 items = new TextLabel[5];
43 for (int i = 0; i < 5; i++)
45 items[i] = new TextLabel
47 Position = new Position(0, i * 100),
48 Size = new Size(800, 100),
50 TextColor = Color.Black,
54 items[i].BackgroundColor = Color.White;
58 items[i].BackgroundColor = Color.Cyan;
60 mScrollableBase.Add(items[i]);
62 root.Add(mScrollableBase);
65 private void OnScrollOutOfBound(object sender, Components.ScrollOutOfBoundEventArgs e)
67 if (e.Displacement > 100)
69 if (e.PanDirection == Components.ScrollOutOfBoundEventArgs.Direction.Down)
71 items[0].Text = $"Reached at the top, panned displacement is {e.Displacement}.";
74 else if (0 - e.Displacement > 100)
76 if (e.PanDirection == Components.ScrollOutOfBoundEventArgs.Direction.Up)
78 items[4].Text = $"Reached at the bottom, panned displacement is {e.Displacement}.";
83 public void Deactivate()
85 for (int i = 0; i < 5; i++)
89 mScrollableBase.Remove(items[i]);
93 if (mScrollableBase != null)
95 root.Remove(mScrollableBase);
96 mScrollableBase.Dispose();