You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MAUI/PDF-Viewer/Scrolling.md
+36-34Lines changed: 36 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,56 +1,32 @@
1
1
---
2
2
layout: post
3
3
title: Scrolling in .NET MAUI PDF Viewer Control | Syncfusion
4
-
description: Learn here all about scrolling functionality in .NET MAUI PDF Viewer including programmatically setting scroll positions and detecting scroll changes.
4
+
description: Explore scrolling features in .NET MAUI PDF Viewer, including how to set scroll positions programmatically and detect scroll changes in real time.
5
5
platform: MAUI
6
6
control: SfPdfViewer
7
7
documentation: ug
8
8
---
9
9
10
10
# Scrolling in .NET MAUI PDF Viewer (SfPdfViewer)
11
11
12
-
The NET MAUI PDF Viewer has scrolling capabilities that allow users to navigate through content seamlessly. This section will walk you through various aspects of scrolling, including programmatically setting scroll positions and detecting scroll changes.
12
+
The .NET MAUI PDF Viewer provides built-in scrolling capabilities that allow users to navigate through PDF content smoothly. This guide covers how to control scroll positions programmatically, detect scroll changes, and manage scroll-related UI elements.
13
13
14
-
W> Please note that since the PDF Viewer has built-in scrolling capability, it is advised to avoid placing the PDF Viewer inside other controls that also offer scrolling, such as [ScrollView](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/scrollview?view=net-maui-8.0). Nesting within such controls may cause unexpected issues.
14
+
W> Since the PDF Viewer includes built-in scrolling, avoid placing it inside other scrollable containers like [ScrollView](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/scrollview?view=net-maui-8.0), as this may lead to unexpected behavior.
15
15
16
-
## Scroll Head
16
+
## Programmatic Scrolling
17
17
18
-
You can scroll through pages by simply dragging the scroll head within the UI on Android and iOS platforms.
19
-
20
-

21
-
22
-
### Page navigation using scroll head
23
-
To navigate to a specific page, tap the scroll head to open the page navigation dialog. Enter a valid page number in the input field present in the dialog, then tap the OK button. Then it navigates to the selected page of the PDF document. Refer to below reference video.
24
-
25
-

26
-
27
-
### Show or hide the scroll head
28
-
29
-
The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to show or hide the scroll head thumb displayed using the [ShowScrollHead](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ShowScrollHead) property. Refer to the following code example.
30
-
31
-
{% tabs %}
32
-
{% highlight c# %}
33
-
// Hide the scroll head thumb
34
-
PdfViewer.ShowScrollHead = false;
35
-
{% endhighlight %}
36
-
{% endtabs %}
37
-
38
-
N> The Scroll Head is not available for the Desktop platform (Windows and MAC)
39
-
40
-
## Navigate to the desired offset programmatically
41
-
42
-
The [ScrollToOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ScrollToOffset_System_Double_System_Double_) method moves the scroll position of the SfPdfViewer to the specified horizontal and vertical offsets. If the specified offset value is wrong, the scroll will not happen, and the older position will be retained. The offset values are represented in device-independent units.
18
+
Use the [ScrollToOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ScrollToOffset_System_Double_System_Double_) method to scroll to a specific horizontal and vertical offset. Offset values are measured in **device-independent units**. If the specified offset is invalid or out of bounds, the scroll action will be ignored and the viewer will retain its current position.
43
19
44
20
{% tabs %}
45
21
{% highlight c# %}
46
-
// Navigate to the scroll offset position (100,1000).
22
+
// Scroll to position (100,1000)
47
23
PdfViewer.ScrollToOffset(100, 1000);
48
24
{% endhighlight %}
49
25
{% endtabs %}
50
26
51
-
## Scroll changes detection
27
+
## Detect Scroll Changes
52
28
53
-
The `PropertyChanged` event can be used to identify the scroll changes in the PDF Viewer effectively. By monitoring the [HorizontalOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_HorizontalOffset) and [VerticalOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_VerticalOffset) property changes, you can respond to both the horizontal and vertical scroll movements respectively.
29
+
You can monitor scroll changes using the `PropertyChanged` event. By monitoring the [HorizontalOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_HorizontalOffset) and [VerticalOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_VerticalOffset) property changes, you can respond to both the horizontal and vertical scroll movements respectively.
54
30
55
31
The following is the code example for subscribing to the `PropertyChanged` event.
Handle scroll changes by implementing the event handler method. The following code example illustrates how to respond to both horizontal and vertical scroll changes:
52
+
The following code example illustrates how implement the event handler and to respond to both horizontal and vertical scroll changes:
On Android and iOS platforms, the scroll head offers a quick way to move through pages. Users can drag the thumb indicator to scroll within the PDF document.
119
+
120
+

121
+
122
+
### Page Navigation via Scroll Head
123
+
124
+
Tap the scroll head to open a page navigation dialog. Enter a valid page number and tap **OK** to jump directly to that page.
125
+
126
+

127
+
128
+
### Show or Hide the Scroll Head
129
+
130
+
Use the [ShowScrollHead](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ShowScrollHead) property to control the visibility of the scroll head.
131
+
132
+
{% tabs %}
133
+
{% highlight c# %}
134
+
// Hide the scroll head thumb
135
+
PdfViewer.ShowScrollHead = false;
136
+
{% endhighlight %}
137
+
{% endtabs %}
138
+
139
+
N> The scroll head is available only on **mobile platforms**. It is not supported on **Windows** or **macOS**.
0 commit comments