Chamath Viduranga
Chamath Viduranga

Reputation: 145

How to add Xamarin PinView in cross platform app and set it as starting view?

I want to add Pinview to this project and set it as starting page. this is code view and the xaml.

[XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class PinView : ContentView
    {
        public PinView ()
        {
            InitializeComponent ();
        }
    }


<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:local="clr-namespace:FormsPinView.Core;assembly=FormsPinView.Core" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="AllianceHire.Views.PinView">
   <ContentView.Content>
      <StackLayout>
         <Label Text="Hello Xamarin.Forms!" />
      </StackLayout>
   </ContentView.Content>
</ContentView>

Upvotes: 0

Views: 303

Answers (1)

nevermore
nevermore

Reputation: 15806

The Application base class offers the following features, which are exposed in your projects default App subclass:

  • A MainPage property, which is where to set the initial page for the app.

So to set up as PinView as starting page, go to App.xaml.cs, assign the PinView as MainPage:

public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        MainPage = new PinView();
    }
}

public partial class PinView : ContentView
{
    public PinView()
    {
        InitializeComponent();
    }
}

Read document about more detail information: application-class

Upvotes: 1

Related Questions