Skip to content

Instantly share code, notes, and snippets.

View markjulmar's full-sized avatar

Mark Smith markjulmar

View GitHub Profile
@markjulmar
markjulmar / move-repo.sh
Created August 29, 2016 15:45
Move Git repo
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@markjulmar
markjulmar / WPFvForms.md
Created April 28, 2017 22:14
Comparing WPF and Forms

WPF vs. Xamarin.Forms

Xamarin.Forms takes a lot of design guidance from the XAML-based frameworks that came before it, particularly WPF. However, in other ways it deviates significantly which can be a sticky point for people attempting to migrate over. This document attempts to identify some of those issues and provide guidance where possible to bridge WPF knowledge to Xamarin.Forms.

App Lifecycle

The application lifecycle between WPF and Xamarin.Forms is similar. Both start in external (platform) code and launch the UI through a method call. The difference is that Xamarin.Forms always starts in a platform-specific assembly which then initializes and creates the UI for the app.

WPF

Main method > App > MainWindow
@markjulmar
markjulmar / DisplayAlert
Created June 30, 2017 01:47
Show DisplayAlert from background thread.
private void Button_Clicked(object sender, EventArgs e)
{
Task.Run(() => OnShowAlert("Hello"));
}
private void OnShowAlert(string text)
{
string title = $"OnShowAlert tid={Environment.CurrentManagedThreadId}";
Device.BeginInvokeOnMainThread(
async () => await DisplayAlert(title, text, "OK"));
@markjulmar
markjulmar / UWPDeviceType.cs
Last active July 11, 2017 13:15
Detect UWP device type
public enum DeviceType
{
Phone,
Tablet,
Desktop,
IoT,
Xbox,
SurfaceHub,
HoloLens,
Other