Skip to content

Instantly share code, notes, and snippets.

View benoitjadinon's full-sized avatar

Benoit Jadinon benoitjadinon

View GitHub Profile
@benoitjadinon
benoitjadinon / BindableObjectExtensions.cs
Last active September 16, 2015 23:46
Xamarin.Forms: Chainable and Strongly-Typed SetBinding() Extension
public static class BindableObjectExtensions
{
// chainable, with a string for property
// usage : new Button().WithBinding(Button.CommandProperty, "SomeCommand"),
public static T WithBinding<T>(this T obj,
BindableProperty bindableProperty,
string path,
BindingMode mode = BindingMode.Default,
IValueConverter converter = null,
@Cheesebaron
Cheesebaron / DummyFragment.cs
Created September 6, 2014 15:43
Removing Fragments from ViewPager
public class DummyFragment : Fragment
{
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var view = inflater.Inflate(Resource.Layout.dummy_frag, container, false);
var tv = view.FindViewById<TextView>(Resource.Id.textView1);
tv.Text = "" + Arguments.GetInt("number", -1);
return view;
}
}
@hjerpbakk
hjerpbakk / BindablePicker.cs
Created July 17, 2014 19:26
A Picker-control for Xamarin.Forms which enables data binding through an ItemsSource and the SelectedItem.
using System;
using Xamarin.Forms;
using System.Collections;
namespace YourNamespace.Views.Controls {
public class BindablePicker : Picker
{
public BindablePicker()
{
this.SelectedIndexChanged += OnSelectedIndexChanged;
@staltz
staltz / introrx.md
Last active October 26, 2025 03:06
The introduction to Reactive Programming you've been missing
@AArnott
AArnott / ObservableCollectionAdapter.cs
Created March 12, 2014 19:19
A Xamarin.Android class that provides data binding from an ObservableCollection<T> to a ListView in the form of a BaseAdapter<T>.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
@AArnott
AArnott / ActivityBase.cs
Created February 11, 2014 15:53
A C# Xamarin.Android activity base class that offers StartActivityForResultAsync as a much simpler means to kick off activities and resume execution when they are done.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
public abstract class ActivityBase : Activity {
private int activityResultRegistrationCounter = 10000;
@Clancey
Clancey / gist:7610128
Last active December 29, 2015 03:49
Background Downloader. Has the same API as WebClient but uses the underlying NSUrlRequest to download in the background.
public class BackgroundDownload
{
public BackgroundDownload ()
{
}
NSUrlSessionDownloadTask downloadTask;
static NSUrlSession session;
public async Task DownloadFileAsync(Uri url, string destination)
{
if (downloadTask != null)
@nicwise
nicwise / gist:7026601
Created October 17, 2013 15:07
using async/await and a task completion source to work with NavigationController etc.
//start with DoAdd, which comes off a button push.
// it does pop up one screen, then another one, which is not ideal,
// but it wouldn't be hard to adapt.
async void DoAdd ()
{
var camera = await PickCameraForLoad ();
if (camera != null)
{
@briangriffey
briangriffey / NinePatchBitmapFactory.java
Last active December 3, 2024 01:35
Create 9-patches simlar to - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.NinePatch;
import android.graphics.Rect;
import android.graphics.drawable.NinePatchDrawable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
declare interface AngularVersion {
full: string;
major: number;
minor: number;
dot: number;
codeName: string;
}
declare interface AngularModule {
requires: string[];