![](/img/trans.png)
[英]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.