Skip to content

Instantly share code, notes, and snippets.

View twolfprogrammer's full-sized avatar

Thomas Wolf twolfprogrammer

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:HelloForms"
x:Class="HelloForms.HelloFormsPage">
<Label
Text="Hello Xamarin.Forms"
VerticalOptions="Center"
HorizontalOptions="Center" />
using Xamarin.Forms;
namespace HelloForms {
public partial class App : Application {
public App() {
InitializeComponent();
MainPage = new HelloFormsPage();
}
protected override void OnStart() {
using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace HelloForms.Droid {
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace HelloForms.iOS {
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate {
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace HelloForms.iOS {
public class Application {
// This is the main entry point of the application.
<?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="MyProjectName.CustomContentPage" ControlTemplate="{StaticResource MainPageTemplate}">
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0" />
</ContentPage.Padding>
</ContentPage>
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyProjectName.App">
<Application.Resources>
<!-- Application resource dictionary -->
<ResourceDictionary>
<ControlTemplate x:Key="MainPageTemplate">
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<BoxView BackgroundColor="Aqua" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="5"/>
<Button Image="BackIcon" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="1" Command="GoBack"/>
<Image Source="Logo" Aspect="AspectFit" BackgroundColor="Transparent" Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="1"/>
</Grid>
...
public CustomContentPage() {
NavigationPage.SetHasNavigationBar(this, false);
...
}
...
public MainPageViewModel() {
...
var database = new Database("People"); // Creates (if does not exist) a database named People
database.CreateTable<Person>(); // Creates (if does not exist) a table of type Person
...
}