Computer Magic Logo
Page size change

Monday, April 11, 2016

Published by Aristotelis Pitaridis

The SizeChanged event of of a page informs us when the size of the page has been changed. The following example shows how to catch the event and display the new page size on the screen using a label.

public partial class Page1 : ContentPage
{
    public Page1 ()
    {
        InitializeComponent ();

        SizeChanged += Page1_SizeChanged;
    }

    private void Page1_SizeChanged(object sender, EventArgs e)
    {
        MyLabel.Text = String.Format("{0} x {1}", Width, Height);
    }
}