Sgt Maddonut
Sgt Maddonut

Reputation: 779

TabbedPage in Xamarin

I'm trying to make TabbedPage in Xamarin

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();
        }
    }
}

But I get Error: The given key 'Xamarin.Forms.Xaml.ElementNode' was not present in the dictionary

The error dissapears when I remove User user from public UserPage(User user). But I need to use this class in constructor later.

Upvotes: 0

Views: 136

Answers (1)

Sgt Maddonut
Sgt Maddonut

Reputation: 779

Solved by adding second constructor without parameters

Upvotes: 0

Related Questions