Skip to content

Instantly share code, notes, and snippets.

using Definition.Interfaces;
using Mobile.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace Mobile.View
// Pass parameter to view model
var model = page.BindingContext as BaseViewModel;
if (model != null)
await model.OnNavigated(parameter);
<Button Command="{Binding LoginCommand}" Text="Login" />
private RelayCommand _loginCommand;
public RelayCommand LoginCommand
{
get
{
return _loginCommand
?? (_loginCommand = new RelayCommand(
async () =>
private LoginModel _model = null;
public LoginModel Model
{
get
{
return _model;
}
set
{
if (value != _model)
public string Username
{
get
{
return _model.Username;
}
set
{
_model.Username = value;
var uniqueKey = System.Guid.NewGuid().ToString();
var model = SimpleIoc.Default.GetInstance<LoginModel>(uniqueKey);
// Must remmeber to cleanup, otherwise all new instances are cached
SimpleIoc.Default.Unregister(uniqueKey);
public partial class BindablePicker : Picker
{
public BindablePicker()
{
InitializeComponent();
this.SelectedIndexChanged += OnSelectedIndexChanged;
}
public static BindableProperty ItemsSourceProperty =
@adamped
adamped / ISQLite
Created January 8, 2016 01:36
SQLite Interface For Xamarin Forms
public interface ISQLite {
void CloseConnection();
SQLiteAsyncConnection GetAsyncConnection();
void DeleteDatabase();
}
@adamped
adamped / SQLite_WinPhone
Created January 8, 2016 01:47
SQLite for WinPhone
public class SQLite_WinPhone : ISQLite
{
private static SQLiteConnectionWithLock _conn;
public SQLite_WinPhone() { }
private static Object _connectionLock = new Object();
private string DatabaseName = "DatabaseName.db3";
@adamped
adamped / SQLite_Android
Created January 8, 2016 02:14
SQLite for Android
public class SQLite_Android : ISQLite
{
private SQLiteConnectionWithLock _conn;
public SQLite_Android()
{
}