> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/guides/viewer-components/thumbnail-slider-i.md).

# Adding PDF page slider in Xamarin

Learn how to create and customize a thumbnail slider in Xamarin.iOS using PTThumbnailSliderViewController. Enhance document navigation with page previews and scroll indicators. Add the Tools library t

{% hint style="info" %}
**This tutorial only applies to Xamarin.iOS. See Xamarin.Android equivalent here .**
{% endhint %}

The [`PTThumbnailSliderViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTThumbnailSliderViewController.html) class allows the user to quickly navigate through a document. When using the slider control, a small page preview pop will be shown on top of the thumbnail slider.

Note: If you are using the new UI, we recommend the `PTDocumentSliderViewController` class, which displays a scroll indicator for the current scroll position and allows the user to quickly skip through pages.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-f9febe07a85d44675b5ad03e550640c736bf7123%2Fd737ad4d9851f59b5429599867cdb1e68b062fc8-750x615.png?alt=media)

*The thumbnail slider control is part of the Tools library, so make sure you have* [*added the Tools library to your project*](/xamarin/ui-customization/setup.md)*.*

## Show a thumbnail slider

To create and set up a thumbnail slider, supply a `PTPDFViewCtrl` instance to the `PTThumbnailSliderViewController` designated initializer:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
var thumbnailSlider = new pdftron.PDF.Controls.PTThumbnailSliderViewController(mPdfViewCtrl);

AddChildViewController(thumbnailSlider);
View.AddSubview(thumbnailSlider.View);

thumbnailSlider.View.TranslatesAutoresizingMaskIntoConstraints = false;

NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
    thumbnailSlider.View.LeadingAnchor.ConstraintEqualTo(this.View.LeadingAnchor),
    thumbnailSlider.View.WidthAnchor.ConstraintEqualTo(this.View.WidthAnchor),
    thumbnailSlider.View.BottomAnchor.ConstraintEqualTo(this.View.BottomAnchor)
});
thumbnailSlider.DidMoveToParentViewController(this);
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Populate with thumbnail images

The thumbnail images shown in the thumbnail slider view controller are generated by the `GetThumbAsync:` method of the `PTPDFViewCtrl` class. When ready, the thumbnail images are provided to the `pdfviewCtrl`'s delegate via the `pdfViewCtrl:gotThumbAsync:thumbImage:` method.

In your class adopting the `PTPDFViewCtrlDelegate` protocol (usually the same view controller containing the thumbnail slider view controller), add the following:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
mPdfViewCtrl.GotThumbAsync += (sender, e) =>
{
    if (e.Image == null)
    {
        return;
    }
    this.thumbnailSlider?.SetThumbnail(e.Image, e.Page_num);
};
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Customization

The [`PTThumbnailSliderViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTThumbnailSliderViewController.html) provides a flexible API for displaying buttons on either side of the slider control. This is possible with the following properties:

[`LeadingToolbarItem`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTThumbnailSliderViewController.html#pdftron_PDF_Controls_PTThumbnailSliderViewController_LeadingToolbarItem) - a single `UIBarButtonItem` to the left of the slider.[`LeadingToolbarItems`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTThumbnailSliderViewController.html#pdftron_PDF_Controls_PTThumbnailSliderViewController_LeadingToolbarItems) - an array of `UIBarButtonItem`s to the left of the slider.[`TrailingToolbarItem`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTThumbnailSliderViewController.html#pdftron_PDF_Controls_PTThumbnailSliderViewController_TrailingToolbarItem) - a single `UIBarButtonItem` to the right of the slider.[`TrailingToolbarItems`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTThumbnailSliderViewController.html#pdftron_PDF_Controls_PTThumbnailSliderViewController_TrailingToolbarItems) - an array of `UIBarButtonItem`s to the right of the slider.

It is also possible to remove these buttons by setting the appropriate property to nil.

For example, to show a button to present a [`PTThumbnailsViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTThumbnailsViewController.html) on the left of the slider, and a button to present a [`PTNavigationListsViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTNavigationListsViewController.html) on the right:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// add a custom UIBarButtonItem to the left of the thumbnail slider
thumbnailSlider.LeadingToolbarItem = new UIBarButtonItem(UIImage.FromFile("icon.png"), UIBarButtonItemStyle.Plain, (sender, e) => {
	// perform custom action
});

// add an array of UIBarButtonItems to the right of the slider
var button1 = new UIBarButtonItem(UIImage.FromFile("icon1.png"), UIBarButtonItemStyle.Plain, (sender, e) => {
    // perform custom action
});
var button2 = new UIBarButtonItem(UIImage.FromFile("icon2.png"), UIBarButtonItemStyle.Plain, (sender, e) => {
    // perform custom action
});
documentViewController.ThumbnailSliderController.TrailingToolbarItems = new UIBarButtonItem[] {button1, button2};

// remove the buttons from the left of the slider by setting the property to null
documentViewController.ThumbnailSliderController.LeadingToolbarItems = null;
```

{% endcode %}
{% endtab %}
{% endtabs %}

## The thumbnail slider delegate

The `PTThumbnailSliderViewDelegate` protocol allows the adopting class (usually the containing view controller, as in this guide) to be notified when the user is actively using the thumbnail slider. The thumbnail slider already handles changing the current page in response to user actions, but the delegate methods can be used to hide or show other content as appropriate.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/xamarin/guides/viewer-components/thumbnail-slider-i.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
