gpt4 book ai didi

c# - Xamarin 表单如何重叠?

转载 作者:可可西里 更新时间:2023-11-01 03:06:23 24 4
gpt4 key购买 nike

z-index有没有概念?图片显示没有重叠。 enter image description here如何设置z-index?前两个自定义选择框

<AbsoluteLayout Padding="10,10,10,10" VerticalOptions="FillAndExpand">

<ui:BoxSelector x:Name="selectorExchangs"
AbsoluteLayout.LayoutBounds="0,0,0.5,0.3"
AbsoluteLayout.LayoutFlags="All"
BackgroundColor="Transparent"
CommandAfterChanged="{Binding ExchangesAfterChangedCommand}"
Items="{Binding ExchangesList}"
LabelPath="Name"
PanelColor="#f9f9f9"
SelectedItem="{Binding SelectedExchange}"
SelectorLabel="EXCHANGE" />

<ui:BoxSelector AbsoluteLayout.LayoutBounds="1,0,0.5,0.3"
AbsoluteLayout.LayoutFlags="All"
BackgroundColor="Transparent"
CommandAfterChanged="{Binding TradingPairAfterChangedCommand}"
Items="{Binding AvailableTradinPairsList}"
LabelPath="PriceCurrencyName"
PanelColor="#f9f9f9"
SelectedItem="{Binding SelectedTraingPair}"
SelectorLabel="CURRENCY" />

还有其他的。图表、数据等

    <StackLayout AbsoluteLayout.LayoutBounds="1,1,1,0.9" AbsoluteLayout.LayoutFlags="All">...</StackLayout>

BoxSelector.xaml(content view),可重用的ContentView扩展

<ContentView.Resources>
<ResourceDictionary x:Name="AppDictionary">
<Color x:Key="BackgroundColor">#f9f9f9</Color>
<Color x:Key="BorderColor">#e2e2e2</Color>
<Style x:Key="InternalViewStyle" TargetType="ContentView">
<Setter Property="BackgroundColor" Value="{StaticResource BackgroundColor}" />
<Setter Property="VerticalOptions" Value="Fill" />
<Setter Property="Padding" Value="5,5,5,5" />
</Style>
<Style x:Key="BorderStyle" TargetType="ContentView">
<Setter Property="BackgroundColor" Value="{StaticResource BorderColor}" />
<Setter Property="Padding" Value="1,1,1,1" />
</Style>
</ResourceDictionary>
</ContentView.Resources>

<StackLayout BindingContext="{x:Reference Name=ContentView}" HorizontalOptions="FillAndExpand">
<ContentView BackgroundColor="#f5f5f5" HorizontalOptions="FillAndExpand">
<StackLayout>
<ContentView Style="{StaticResource BorderStyle}">
<ContentView Style="{StaticResource InternalViewStyle}">
<StackLayout Orientation="Horizontal">
<StackLayout x:Name="selectorBox"
BackgroundColor="{Binding PanelColor}"
HorizontalOptions="FillAndExpand"
Orientation="Horizontal">
<StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal">
<Label FontSize="12"
HorizontalOptions="FillAndExpand"
Text="{Binding SelectorLabel}"
TextColor="#cccccc" />
<Label x:Name="valueLabe"
BackgroundColor="{Binding PanelColor}"
FontSize="13"
HorizontalOptions="FillAndExpand"
Text="Choose"
TextColor="#313131" />
</StackLayout>
<StackLayout HorizontalOptions="EndAndExpand">
<Label Text="+" TextColor="#313131" />
</StackLayout>
</StackLayout>
</StackLayout>
</ContentView>
</ContentView>

<Grid x:Name="boxSelectorGrid"
BackgroundColor="#f5f5f5"
Padding="10,10,10,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid>

</StackLayout>
</ContentView>
</StackLayout>

最佳答案

Z-Index 是根据容器元素中子元素的顺序建立的。第一个 child 在 Z 堆栈的后面,第二个 child 放在它上面,依此类推。

您使用的布局容器将决定每个子项的定位方式。 StackLayout 不允许重叠。 AbsoluteLayoutRelativeLayout 将允许轻松重叠。 Grid 将允许延伸到同一行和列的元素重叠。这些都没有自己的外观(默认情况下将它们视为透明框)。如果您希望它们遮挡住它们后面的内容,那么您需要指定背景颜色或图像,否则它们只会被绘制在其他内容之上。

关于c# - Xamarin 表单如何重叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37566509/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com