在Xamarin.Forms中,当旋转手机时,我想隐藏某些XAML组件。我似乎找不到简单易用的xamarin提供的任何东西...有人可以向我指出正确的方向吗?
谢谢
答案 0 :(得分:1)
在Xamarin.Forms Page
中,您可以订阅SizeChanged
事件或重写OnSizeAllocated
方法。有一些不错的documentation描述了这两种选择。以下是使用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
}
}
}