xaml - 在其他页面顶部显示布局并使其永远不会关闭,即使内容页面发生更改
问题描述
我正在尝试实现一个位于所有其他内容视图之上的布局。甚至当您离开当前导航时,ContentView
主布局仍保持在其位置上。我尝试通过在顶部显示内容视图而不是全屏来实现这一点,但即使我将高度属性设置为ContentView
它,它也将始终显示全屏。
所以我决定制作三个网格,其中两个是透明的,一个是纯色的。使用 PopUp 插件,这似乎奏效了,但是现在您无法单击基础内容页面上的任何内容,因为透明网格仍会阻止单击。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" BackgroundColor="Transparent">
</Grid>
<Grid Grid.Row="1" BackgroundColor="Green">
</Grid>
<Grid Grid.Row="2" BackgroundColor="Transparent">
</Grid>
</Grid>
我将如何继续这件事?我可以使用第三方库。
解决方案
Using the RG PopUp PlugIn this is achievable like so:
<pages:PopupPage
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns="http://xamarin.com/schemas/2014/forms"
HeightRequest="200"
BackgroundColor="#00000000"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
mc:Ignorable="d"
InputTransparent="True"
x:Class="InteriorCircle.Pages.PopUps.PopUp_FloatingInfo">
<pages:PopupPage.Animation>
<animations:ScaleAnimation DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8" />
</pages:PopupPage.Animation>
<!-- takes whole page, so upper and lower grid are just to leave parts transparent-->
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" BackgroundColor="Transparent" InputTransparent="true" >
</Grid>
<Grid Grid.Row="1" BackgroundColor="Transparent">
<BoxView BackgroundColor="White" CornerRadius="20"/>
</Grid>
</Grid>
</pages:PopupPage>