Xamarin 中的 TabbedPage
TabbedPage in Xamarin
我正在尝试在 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'
当我从 public UserPage(User user)
中删除 User user
时,错误消失了。但是我需要稍后在构造函数中使用这个class。
通过添加第二个不带参数的构造函数解决
我正在尝试在 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'
当我从 public UserPage(User user)
中删除 User user
时,错误消失了。但是我需要稍后在构造函数中使用这个class。
通过添加第二个不带参数的构造函数解决