【发布时间】:2015-08-26 06:36:15
【问题描述】:
我想在 Xamarin.Forms 中通过控件后面的代码中的一些事件来更改控件的大小。
特别是,我想在设备方向改变时改变 StackLayout 的大小。
目前,我已经这样做了(但它不起作用):
private void SettingsPage_OnSizeChanged(object sender, EventArgs e)
{
var isPortrait = UIHelpers.IsPortrait(this);
if (isPortrait)
RemoteServerSL.WidthRequest = RemoteServerSL.ParentView.Width;
else
{
RemoteServerSL.WidthRequest = RemoteServerSL.ParentView.Width/2;
}
this.UpdateChildrenLayout();
this.ForceLayout();
RemoteServerSL.ForceLayout();
}
如果我处于横向模式,目的是将我的 StackLayout 的宽度更改为 parentWidth。
我该如何处理?
顺便说一句。我现在正在使用 Android。
【问题讨论】:
标签: c# xamarin.forms