如何使用PCL项目在Xamarin中为Android和iOS开发应用程序?

时间:2017-04-26 14:55:20

标签: c# xamarin xamarin.ios xamarin.android

我创建了一个Xamarin PCL项目,它有Android iOS和Portable。我看了几个例子,你可以使用Xaml创建一个登录页面,然后使用CS文件验证这些凭据,但我的问题是我可以说我验证了这些凭据,我该如何从那个通用的UI页面我认为是Android或iOS部分吗?

我从哪里开始?

对不起,如果我天真,我是Xamarin的新手,任何帮助都将不胜感激。

这是我提到便携式的样本,

using System;
using Xamarin.Forms;

namespace StoreCredentials
{
    public class HomePageCS : ContentPage
    {
        public HomePageCS ()
        {
            var toolbarItem = new ToolbarItem {
                Text = "Logout"
            };
            toolbarItem.Clicked += OnLogoutButtonClicked;
            ToolbarItems.Add (toolbarItem);

            Title = "Home Page";
            Content = new StackLayout { 
                Children = {
                    new Label {
                        Text = "Main app content goes here",
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions = LayoutOptions.CenterAndExpand
                    }
                }
            };
        }

        async void OnLogoutButtonClicked (object sender, EventArgs e)
        {
            DependencyService.Get<ICredentialsService> ().DeleteCredentials ();
            Navigation.InsertPageBefore (new LoginPage (), this);
            await Navigation.PopAsync ();
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我建议你在潜入Xamarin之前阅读this。 此外,this因为它与你想要做的事情有关。

相关问题