我正在尝试使用AbsoluteLayout显示弹出窗口。单击按钮,我将stacklayout设置为可见。但是没有显示
<AbsoluteLayout x:Name="absoluteLayout">
<StackLayout x:Name="layout1"
BackgroundColor="White"
Spacing="1"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All">
<StackLayout>
<StackLayout x:Name="popupLayout"
BackgroundColor="Gray"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
IsVisible="False"
Spacing="0">
//Content
</StackLayout>
</AbsoluteLayout>
在按钮上单击,将可见性设置为true
public void OnButtonClick(object sender, EventArgs args){
popupLayout.IsVisible = true;
}
我试图将popupLayout的可见性在onappear中设置为false,然后在按钮单击时启用,仍然具有相同的行为。
更新:增加代码细节。通过设置popupLayout的背景,我知道按钮点击布局是可见的,但它的内容/子不显示。我们应该分别启用子视图/元素吗?
试试这个
public void OnButtonClick(object sender, EventArgs args){
popupLayout.IsVisible = true;
popupLayout.ForceLayout();
}
或
public void OnButtonClick(object sender, EventArgs args){
popupLayout.IsVisible = true;
popupLayout.Parent.ForceLayout();
}