??? Similar methods allow horizontal scrolling, including LineLeft(), LineRight(),
PageLeft(), and PageRight().
??? Finally, you can use the ScrollToXxx() methods to go somewhere specific. For vertical
scrolling, they include ScrollToEnd() and ScrollToHome(), which take you to the top
or bottom of the scrollable content, and ScrollToVerticalOffset(), which takes you to a
specific position. There are horizontal versions of the same methods, including
ScrollToLeftEnd(), ScrollToRightEnd(), and ScrollToHorizontalOffset().
CHAPTER 5 n CONTENT 127
Figure 5-6 shows an example where several custom buttons allow you to move through
the ScrollViewer. Each button triggers a simple event handler that uses one of the methods in
the previous list.
Figure 5-6. Programmatic scrolling
Custom Scrolling
The built-in scrolling in the ScrollViewer is quite useful. It allows you to scroll slowly through
any content, from a complex vector drawing to a grid of elements. However, one of the most
intriguing features of the ScrollViewer is its ability to let its content participate in the scrolling
process. Here??™s how it works:
??? You place a scrollable element inside the ScrollViewer. This is any element that implements
IScrollInfo.
??? You tell the ScrollViewer that the content knows how to scroll itself by setting the
ScrollViewer.
Pages:
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270