现在,我的ContentView(就像一个弹出窗口)堆叠在我的网格上,见下面的代码:
<StackLayout>
<ContentView>...</>
<StackLayout>
<Grid>...</>
</StackLayout>
</StackLayout>
网格是一个表单,所以当我按下表单中的一个按钮时,我希望一个新的弹出窗口(contentview)出现在网格的上方,位于屏幕的中心。这样做的目的是,您仍然可以看到contentview后面的一些表单。
如何将contentview放在前面,而不是堆叠在网格的顶部?
<ContentView x:Name="popupAddDetails" AbsoluteLayout.LayoutBounds="0,0,1,1"
VerticalOptions="Center" HorizontalOptions="Center">
PS:我是新来的,还在学习中,非常感谢你的帮助
我试着在我的第一个stacklayout上面做一个stacklayout,把我的网格放在里面,然后在我的contentview中设置垂直和水平属性,但是它只是堆叠在我的内部stacklayout上面。
1条答案
按热度按时间qgzx9mmu1#
您可以简单地使用Xamarin社区工具包弹出窗口来创建它。
首先,向您的项目添加一个名为Xamarin.CommunityToolkit的新Nuget。
然后,创建一个弹出页面,当你点击一个按钮时就会显示出来。这与创建一个ContentPage非常相似。
.cs可能如下所示:
最后,您可能希望通过按钮单击事件打开此弹出页面。不要忘记添加以下行:
我创建了这个演示,它运行得很好。你可以参考Xamarin Community Toolkit Popup和Getting Started with the Xamarin Community Toolkit了解更多信息。
==================更新=====
2.使用外部布局作为Grid而不是StackLayout**可能是一种替代方法。**类似如下:
通过这种方式,ContentView将被放置在innerGrid之上。
希望对你有用。