Xamarin中的TabbedPage

时间:2018-09-26 07:46:11

标签: xamarin tabbedpage

我正在尝试在Xamarin中制作TabbedPage

UserTabbedPage.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"
            xmlns:local="clr-namespace:MyApp.General.Users.UserProfile;assembly=MyApp"
            x:Class="MyApp.General.Users.UserProfile.UserTabbedPage">
    <local:UserPage />
</TabbedPage>

UserTabbedPage.xaml.cs

using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace MyApp.General.Users.UserProfile
{
    public partial class UserTabbedPage : TabbedPage
    {
        public UserTabbedPage()
        {
            InitializeComponent();
        }
    }
}

UserPage.xaml

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             x:Class="MyApp.General.Users.UserProfile.UserPage">
    <ContentPage.Content>
    </ContentPage.Content>
</ContentPage>

UserPage.xaml.cs

using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace MyApp.General.Users.UserProfile
{
    public partial class UserPage : ContentPage
    {
        public UserPage(User user)
        {
            InitializeComponent();
        }
    }
}

但是我收到错误:字典中不存在给定的键'Xamarin.Forms.Xaml.ElementNode'

当我从User user中删除public UserPage(User user)时,错误消失了。但是我以后需要在构造函数中使用此类。

1 个答案:

答案 0 :(得分:0)

通过添加不带参数的第二个构造函数来解决

相关问题