如何在xaml中的AbsoluteLayout中设置控件的z索引?

如何在xaml中的AbsoluteLayout中设置控件的z索引?,xaml,xamarin.forms,Xaml,Xamarin.forms,我在Xamarin.Forms应用程序的视图上有一个绝对布局,其中有3个按钮。以编程方式添加另一个控件后,它将覆盖按钮。我不知道怎样才能使按钮总是在前面 <ContentPage.Content> <AbsoluteLayout x:Name="Container" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">

我在Xamarin.Forms应用程序的视图上有一个绝对布局,其中有3个按钮。以编程方式添加另一个控件后,它将覆盖按钮。我不知道怎样才能使按钮总是在前面

  <ContentPage.Content>
    <AbsoluteLayout x:Name="Container" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">

        <Button
            Style="{StaticResource CallButtonStyle}"      
             ...                
            AbsoluteLayout.LayoutFlags="PositionProportional"  
            AbsoluteLayout.LayoutBounds=".85,.02" 
            Text="{Binding CameraSwitchIcon}" />

        <Button
            ...
            AbsoluteLayout.LayoutFlags="PositionProportional"  
            AbsoluteLayout.LayoutBounds=".15,.95,80,80"
            Text="{Binding VideoToggleIcon}" />

        <Button
            ...
            AbsoluteLayout.LayoutFlags="PositionProportional"  
            AbsoluteLayout.LayoutBounds=".85,.95,80,80"
            Text="{Binding AudioToggleIcon}" />

    </AbsoluteLayout>
</ContentPage.Content>


所有XF布局都有
RaiseChild()
LowerChild()
方法可用于调整Z索引

您可以使用RaiseChild()和LowerChild()来更改布局的Z顺序element@Jason我会试试看,然后告诉你。非常感谢。@Jason-Hmm,我是这样做的:Container.RaiseChild(SwitchCameraButton);但它没有起作用。我错过什么了吗?SwitchCameraButton是按钮的x:名称。您是在UI线程上执行此操作的吗?这实际上不足以提供帮助。您可以尝试使用MainThread将RaiseChild强制添加到UI线程。