Skip to content

Instantly share code, notes, and snippets.

View twolfprogrammer's full-sized avatar

Thomas Wolf twolfprogrammer

View GitHub Profile
using System;
namespace SQLiteExample {
public enum Gender {
Male,
Female
}
public class Person : BaseItem {
public string FirstName { get; set; }
public string LastName { get; set; }
using System;
using System.Collections.Generic;
using System.Linq;
using SQLite;
using Xamarin.Forms;
namespace SQLiteExample {
public class Database {
static object locker = new object();
ISQLiteService SQLite {
using SQLite;
namespace SQLiteExample {
public class BaseItem {
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
}
}
using System;
using System.IO;
using SQLite;
using Xamarin.Forms;
[assembly: Dependency(typeof(SQLiteExample.Droid.SQLiteService))]
namespace SQLiteExample.Droid {
public class SQLiteService : ISQLiteService {
string GetPath(string databaseName) {
if (string.IsNullOrWhiteSpace(databaseName)) {
using System;
using System.IO;
using SQLite;
using Xamarin.Forms;
[assembly: Dependency(typeof(SQLiteExample.iOS.SQLiteService))]
namespace SQLiteExample.iOS {
public class SQLiteService : ISQLiteService {
string GetPath(string databaseName) {
if (string.IsNullOrWhiteSpace(databaseName)) {
using System;
using SQLite;
namespace SQLiteExample {
public interface ISQLiteService {
SQLiteConnection GetConnection(string databaseName);
long GetSize(string databaseName);
}
}
@twolfprogrammer
twolfprogrammer / MenuPage.xaml.cs
Created September 3, 2016 03:01
Creating a hamburger menu in Xamarin.Forms: replacing HomePage
var otherPage = new OtherPage();
var homePage = App.NavigationPage.Navigation.NavigationStack.First();
App.NavigationPage.Navigation.InsertPageBefore(otherPage, homePage);
App.NavigationPage.PopToRootAsync(false);
@twolfprogrammer
twolfprogrammer / App.xaml.cs
Last active September 6, 2016 22:25
Creating a hamburger menu in Xamarin.Forms
public partial class App : Application {
public NavigationPage NavigationPage { get; private set; }
public App() {
var menuPage = new MenuPage();
NavigationPage = new NavigationPage(new HomePage());
var rootPage = new RootPage();
rootPage.Master = menuPage;
rootPage.Detail = NavigationPage;
MainPage = rootPage;
@twolfprogrammer
twolfprogrammer / RootPage.xaml.cs
Last active September 3, 2016 03:26
Creating a hamburger menu in Xamarin.Forms
public partial class RootPage : MasterDetailPage {
public RootPage() {
InitializeComponent();
MasterBehavior = MasterBehavior.Popover;
}
}
@twolfprogrammer
twolfprogrammer / HomePage.xaml.cs
Last active September 3, 2016 03:26
Creating a hamburger menu in Xamarin.Forms
public partial class HomePage : ContentPage {
public HomePage() {
InitializeComponent();
// Add your UI code here or in your XAML file
}
}