简体   繁体   English

如何在 Xamarin 表单中的 ContentPage 中添加 TabbedPage

[英]How to add TabbedPage inside ContentPage in Xamarin forms

I tried to add TabbedPage inside a content Page so it's not showing any UI.我试图在内容页面中添加TabbedPage ,因此它不显示任何 UI。 I also tried to find a solution but I get: we can't put TabbedPage inside a ContentPage TabbedPage view should be a parent view.我也试图找到一个解决方案,但我得到:我们不能将 TabbedPage 放在 ContentPage 中 TabbedPage 视图应该是父视图。

There are two tab inside a ContentPage i want to replace it with TabbedPage ContentPage 中有两个选项卡,我想用 TabbedPage 替换它

but i have such requirement to add Hi, I tried to add TabbedPage inside a content Page so it's not showing any UI.但我有这样的要求添加 嗨,我试图在内容页面中添加 TabbedPage,因此它不显示任何 UI。 I also tried to find solution but i get we cant put TabbedPage inside a ContentPage TabbedPage view should be parent view我也试图找到解决方案,但我知道我们不能将 TabbedPage 放在 ContentPage 中 TabbedPage 视图应该是父视图

but i have such requirement to add TabbedPage in place of Recent and All.但我有这样的要求添加 TabbedPage 来代替 Recent 和 All。 If any one have any idea please let me update.如果有人有任何想法,请让我更新。

If you are using XAML this can be an useful example for you:如果您使用的是 XAML,这对您来说可能是一个有用的示例:

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             prism:ViewModelLocator.AutowireViewModel="True"
             xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
             xmlns:me="clr-namespace:TabPages;assembly=TabPages"
             x:Class="YourApp.YourPage" BarBackgroundColor="#FF0000">
    <ContentPage Title="Tab 1">
        <StackLayout Padding="4">
            <!-- Content of the first tab -->
        </StackLayout>
    </ContentPage>
    <ContentPage Title="Tab 2">
        <StackLayout Padding="4">
            <!-- Content of the second tab -->
        </StackLayout>
    </ContentPage>
</TabbedPage>

It's difficult to understand your question.很难理解你的问题。 I have not a good English and I think not to have understand your problem.我的英语不好,我认为不了解您的问题。

BTW, it's not possible to add TabbedPage to a ContentPage.顺便说一句,不可能将 TabbedPage 添加到 ContentPage。 You have to add ContentPage to TabbedPage.您必须将 ContentPage 添加到 TabbedPage。

For Example (From Xamarin Docs)例如(来自 Xamarin Docs)

public class MainPageCS : TabbedPage {   public MainPageCS ()   {
    var navigationPage = new NavigationPage (new SchedulePageCS ());
    navigationPage.Icon = "schedule.png";
    navigationPage.Title = "Schedule";

    Children.Add (new TodayPageCS ());
    Children.Add (navigationPage);   } }

The TabbedPage is populated with two child Page objects. TabbedPage 由两个子 Page 对象填充。 The first child is a ContentPage instance, and the second tab is a NavigationPage containing a ContentPage instance.第一个子项是 ContentPage 实例,第二个选项卡是包含 ContentPage 实例的 NavigationPage。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM