Articles in this section
Category / Section

How to use PdfViewer in Xamarin.Forms inside StackLayout?

1 min read

When Xamarin PDF viewer is added to a StackLayout in Xamarin.Forms, it works as expected in Android platform. But in iOS and UWP, the PDF viewer is not visible. This is true regardless of whether the PDF viewer is an immediate child of StackLayout or the StackLayout is at a higher level of parent hierarchy. This is due to the default behavior of StackLayout that it does not show the entire contents of its child if the child’s size is not defined.

 

To make the PdfViewer visible in both iOS and UWP, the HorizontalOptions (if the orientation of the StackLayout is horizontal) or VerticalOptions (if the orientation of the StackLayout is vertical) of the immediate child of the StackLayout must be set to “FillAndExpand”.

 

If the PDF viewer is an immediate child to a StackLayout, set the HorizontalOptions or VerticalOptions of the PDF viewer to “FillAndExpand”. For example, the vertical orientation is used in the following code.

 

XAML

<StackLayout Orientation="Vertical">
   <syncfusion:SfPdfViewer VerticalOptions="FillAndExpand" />
</StackLayout>

 

Sample link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample-1519498600https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample-1519498600

 

If the PDF viewer is at lower level in the child hierarchy of a StackLayout, set the VerticalOptions or HorizontalOptions of the immediate child of the StackLayout to “FillAndExpand”. For example, horizontal orientation is used in the following code.

 

XAML

<StackLayout Orientation="Horizontal">
        <Frame HorizontalOptions="FillAndExpand">
            <Grid>
                <Grid>
                    <syncfusion:SfPdfViewer />
                </Grid>
            </Grid>
        </Frame>
    </StackLayout>

 

Sample link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample1-1997919178https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample1-1997919178

Xamarin PDF Viewer Xaml horizontal orientation

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied