雖然我有C#的經驗,但對Xamarin和XML我還是比較新的。我創建一個XML格式的標籤頁,它是不是在顯示所有Main.axml:TabbedPage和內容頁面不顯示
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mypages="clr-namespace:MainActivity.Pages;assembly=MainActivity"
x:Class="MainActivity.tabPages">
<TabbedPage.Children>
<mypages:Home />
<mypages:AddLocation />
</TabbedPage.Children>
</TabbedPage>
我有2個孩子tabbedpage(Home和添加位置)我要主頁是默認頁面,雖然即使TabbedPage也不會顯示,應用程序是空白的。
Home.axml
<?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="MainActivity.ActualPage" Title="Home" BackgroundColor="Green">
<ContentPage.Content>
<Label Text="Hi there from Page 1" TextColor="White" Font="20"
VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage.Content>
</ContentPage>
MainActivity.cs:
using Android.App;
using Android.Widget;
using Android.OS;
namespace Xonify
{
[Activity(Label = "App", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView (Resource.Layout.Main);
}
}
}
感謝,
馬特
請發佈您的完整代碼 – Pehlaj
您是否將'Main.xaml'(而不是axml)設置爲'App.xaml.cs'中的'MainPage'? –
我加了SetContentView(Resource.Layout.Main);它似乎已經添加了它,雖然它是拋出錯誤錯誤膨脹類TabbedPage – user7834940