Reputation: 1277
In Xamarin.Forms, when the phone is rotated I want to hide certain XAML components. I can't seem to find anything available from xamarin simple to use... can someone point me in the right direction?
thank you
Upvotes: 2
Views: 368
Reputation: 1882
Within a Xamarin.Forms Page
, you could subscribe to the SizeChanged
event or override the OnSizeAllocated
method. There is some good documentation that describes both options. Below is an example of using OnSizeAllocated
:
private double width = 0;
private double height = 0;
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height); //must be called
if (this.width != width || this.height != height)
{
this.width = width;
this.height = height;
if (this.width > this.height)
{
// reconfigure for landscape
}
else
{
// reconfigure for portrait
}
}
}
Upvotes: 1