I am trying to rewrite an app that I wrote for iOS. I was going to write an android version but thought It\'d be better to make this the opportunity to use Xamarin.Forms. Do
Updating for future developers trying to do this that either haven't looked or missed it. The Page class inherits from VisualElement, which now has two properties (which happen to be bindable for use in XAML):
Width - Gets the current rendered width of this element. This is a read-only bindable property. Height - Gets the current rendered height of this element. This is a read-only bindable property.
in your page codebehind you would just do something like:
var myWidth = this.Width;
var myHeight = this.Height;
if you needed to know if it changes, use the SizeChanged event:
public MyPage()
{
SizeChanged += OnSizeChanged;
}
private void OnSizeChanged(object sender, EventArgs e)
{
var myWidth = this.Width;
var myHeight = this.Height;
}
ref: Microsoft Docs