Skip to content

Instantly share code, notes, and snippets.

View jgable's full-sized avatar

Jacob Gable jgable

  • Making Other People Money
  • Redwood City, CA
  • X @jacob4u2
View GitHub Profile
@jgable
jgable / EventToCommandTrigger.cs
Created February 22, 2011 18:58
ClickCommandTrigger from MVVMLight EventToCommand TriggerAction
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using GalaSoft.MvvmLight.Command;
public class ClickCommandTrigger : System.Windows.Interactivity.EventTriggerBase<Button>
{
/// <summary>
@jgable
jgable / CheckedItemCollection.cs
Created February 24, 2011 19:12
CheckedItemCollection for wrapping a collection of checkable items
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Linq;
using System;
/// <summary>
/// A collection of checked items.
/// </summary>
/// <typeparam name="TItem">The type of the item.</typeparam>
public class CheckedItemCollection<TItem> : ObservableCollection<CheckedItemWrapper<TItem>>
@jgable
jgable / DragDropBehaviours.cs
Created February 24, 2011 21:01
An easy to implement DragDropBehavior for incorporating drag and drop in your silverlight 4 application; also includes a FileDragDropBehavior for easy file drag and drop
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interactivity;
/// <summary>
/// A simple file drag and drop behavior.
/// </summary>
public class FileDragDropBehavior : DragDropBehavior<FileInfo[]>
{
@jgable
jgable / UpdateSourceOnTextChanged.cs
Created February 28, 2011 15:52
Updates a source binding for a TextBox when the text changes and not just when the box loses focus.
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Interactivity;
public class UpdateSourceOnTextChanged : Behavior<TextBox>
{
BindingExpression textBinding;
protected override void OnAttached()
{
@jgable
jgable / DataGridColumnBindableHeaderBehavior.cs
Created March 8, 2011 01:45
A simple behavior for adding a bindable column header to a DataGridTextColumn (or any other DataGridColumn)
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;
public class BindableColumnHeader : Behavior<DataGridColumn>
{
/// <summary>
/// The <see cref="Header" /> dependency property's name.
/// </summary>
public const string HeaderPropertyName = "Header";
@jgable
jgable / JsonService.cs
Created March 22, 2011 17:49
A basic JsonService using WebClient and DataContractJsonSerializer for Windows Phone 7, along with an example of how to use it.
using System;
using System.IO;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;
/// <summary>
/// Strongly typed GET and POST utility enum.
/// </summary>
public enum HTTPMethod
@jgable
jgable / Postifier.cs
Created March 22, 2011 18:05
Helps turn any object into a URL Form Encoded string version, including lists of complex objects.
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Extensions to help postify parameters.
/// </summary>
public static class PostifyExtensions
{
private static Postifier postifier = new Postifier();
@jgable
jgable / TeamRepository.cs
Created March 23, 2011 15:19
TeamRepository and Models for a demo project.
using System;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Team information
/// </summary>
public class Team
{
public int Id { get; set; }
@jgable
jgable / MVVMCommon.cs
Created March 23, 2011 19:47
MVVMCommon contains a VM Base and Commanding Helpers for Windows Phone 7 or Silverlight 3
using System;
using System.ComponentModel;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
/// <summary>
/// Base class for Viewmodels providing common INotifyPropertyChanged functionality.
/// </summary>
public abstract class ViewModelBase : INotifyPropertyChanged
@jgable
jgable / HelloWorldVM.cs
Created March 23, 2011 22:37
PivotVM's and MainPage Pivot View for Hackatopia Demo
using System;
using System.Windows;
using System.Windows.Input;
using JSONPhoneApp1.Common;
using JSONPhoneApp1.Service;
public class HelloWorldVM : ViewModelBase
{
private HelloWorldService _helloServ = new HelloWorldService();