我正在为一页中的两张底纸(BS)而苦苦挣扎。在第一个上,我想从 ListView 中选择(点击)带有名称和编号的项目,单击它后 BS1 将隐藏,BS2 将在同一个地方查看,带有两个标签(我选择的名称和编号)。
我应该在哪里写这个逻辑?在 MainPage.cs 中还是在 BottomSheet1.cs 和 BottomSheet2.cs 中?或者,也许你有其他想法?
我正在使用的 BottomSheet:http: //xamaringuyshow.com/2020/06/21/xamarin-forms-bottom-slider/
主页.xaml
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<maps:Map x:Name="map" BackgroundColor="Gray" HorizontalOptions="Fill" VerticalOptions="Fill" Grid.Row="0" Grid.RowSpan="4"/>
<local:BottomSheet1 x:Name="BottomSheetPanCakeLocal" VerticalOptions="EndAndExpand" Grid.Row="1" Grid.RowSpan="3"></local:BottomSheetPanCake>
<local:BottomSheet2 x:Name="BottomSheetUnitPanCakeLocal" Grid.Row="1" Grid.RowSpan="3" VerticalOptions="EndAndExpand"></local:BottomSheetUnitPanCake>
</Grid>
</ContentPage>
BottomSheet1.xaml
<RelativeLayout>
<Grid>
<ListView x:Name="UnitList" ItemsSource="{Binding Units}" RowHeight="60" ItemTapped="UnitList_ItemTapped" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80*" ></ColumnDefinition>
<ColumnDefinition Width="20*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Text="{Binding name}" Grid.Row="0" Grid.Column="0" Margin="15, 10, 0, 0" Style="{StaticResource HighlightedTextsFont}" FontAttributes="Bold"></Label>
<Label Text="{Binding number}" Grid.Row="1" Grid.Column="0" Margin="15, -3 ,0 ,12" Style="{StaticResource secondaryHeader}" ></Label>
<Label Text=">" Grid.RowSpan="2" Grid.Column="1" HorizontalOptions="End" VerticalOptions="Center" TextColor="Gray" Padding="15"></Label>
</Grid>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</RelativeLayout>
BottomSheet2.xaml
<RelativeLayout>
<Grid>
<Label Text="{Binding name}" Grid.Row="0" Grid.Column="0" Style="{StaticResource mainHeader}" ></Label>
<Label Text="{Binding number}" Grid.Row="1" Grid.Column="0" Style="{StaticResource secondaryHeader}" ></Label>
</Grid>
</RelativeLayout>