Xamarin - 使元素出现在网格形式上

Xamarin - make appear element over Grid Form

我有一个使用 ContentPage 中的网格制作的表单,例如:

<ContentPage>
<Grid RowSpacing="0" 
           >
    <Grid.RowDefinitions>
        <RowDefinition Height="90" />
        <RowDefinition Height="1" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>


    <Grid BackgroundColor="{StaticResource TopBackground}" Padding="16" RowSpacing="4" ColumnSpacing="0" 
          >
        <Grid.RowDefinitions>
            <RowDefinition Height="4*" />
            <RowDefinition Height="6*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>


        <Button  Text="BUTTON"
                    FontSize="20" Grid.Row="1" Grid.Column="1"
             />  
    </Grid>


    <BoxView Grid.Row="1" HeightRequest="1" BackgroundColor="{StaticResource ColorSeparador}" HorizontalOptions="FillAndExpand" />

    <ScrollView Grid.Row="2">

        <StackLayout Orientation="Vertical" Margin="16" Spacing="4"
                     >
            <local:ContactEntry HeightRequest="35"  Keyboard="Email" x:Name="emailEntry" "/>

            <Button Margin="0,30,0,50" Grid.Row="9" Text="Send" 
                x:Name="BtnEntrar" Clicked= "onEnviarClicked" B/>  
        </StackLayout>

    </ScrollView>


</Grid>
</ContentPage>

我的问题是当用户发送表单时,我的自定义忙碌指示器元素(避免覆盖整个页面)将出现在表单中心和上方的位置和位置?

     <custom:MyAct
         WidthRequest="150" HeightRequest="150" 
      />  

如果您希望自定义指示器位于中心并覆盖网格的其余内容,只需执行以下操作:

<ContentPage>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="90" />
            <RowDefinition Height="1" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <!-- Your content here -->
        <custom:MyAct
            Grid.Row="0"
            Grid.RowSpan="3"
            WidthRequest="150"
            HeightRequest="150"
            VerticalOptions="Center"
            HorizontalOptions="Center" />  
    </Grid>
</ContentPage>

这样,由于您已经为网格定义了 3 行,因此您的自定义 activity 指标将占用整个网格 space,这要归功于 属性 Grid.RowSpan="3"。此外,指标将出现在网格中的所有其他内容之上,因为它是在 XAML 代码中在它之后定义的。

要使其正常工作,请记住对 hide/show 您的自定义 activity 指标进行必要的绑定。