[英]How to show different items in Flyout item and different items in bottom tab bar using Xamarin forms shell?
[英]How to open popup only instead of page when tab bar (bottom bar) item tap in xamarin forms?
每当我们单击选项卡栏(底部栏)的任何项目时,我只想打开弹出窗口而不是整个页面。 弹出窗口将在任何先前选择的标签栏项目上打开。 例如我们有 5 个标签栏项目。
如果我在 tb item 1 (Page1) 上并单击 tb item 3,它将在 tb item 1 (Page1) 上打开弹出窗口。
我检查了这个插件,但它不允许这样做。
默认情况下, TabbedPage
应将页面作为子页面。 我假设您想在点击 tb 项目 3 时保持在同一页面上。 是tb item 1 tb item 2 tb item 4 ...
取而代之的是,您可以在页面底部创建一个带有 5 个图标的页面。 并包括所有 5 个项目的 OnTapped 手势,项目 3 调用 Pop up ,而其他人则导航到相应的页面。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
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"
mc:Ignorable="d"
x:Class="App1.Views.PageX">
<ContentPage.Content>
<StackLayout>
<StackLayout VerticalOptions="FillAndExpand">
<Label Text="Page content" />
</StackLayout>
<Grid VerticalOptions="End">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ImageButton Source="tab_feed.png"
Grid.Column="0"
Clicked="ImageButton1_Clicked" />
<ImageButton Source="tab_feed.png"
Grid.Column="1"
Clicked="ImageButton2_Clicked" />
<ImageButton Source="tab_feed.png"
Grid.Column="2"
Clicked="ImageButton3_Clicked" />
<ImageButton Source="tab_feed.png"
Grid.Column="3"
Clicked="I mageButton4_Clicked" />
<ImageButton Source="tab_feed.png"
Grid.Column="4"
Clicked="ImageButton5_Clicked" />
</Grid>
</StackLayout>
</ContentPage.Content>
和页面导航
private async void ImageButton1_Clicked (object sender, EventArgs e)
{
await Navigation.PushAsync (new ItemPage1 ());
}
用于弹出
private async void ImageButton3_Clicked(object sender, EventArgs e)
{
await Rg.Plugins.Popup.Contracts.IPopupNavigation.PushAsync(new MyPopupPage(), true);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.