:: Turning gold to chrome

May 27, 2009

Try as I might to avoid any front-end code (though WPF or Windows Forms are less horrible by far than traditional web interfaces), I just know it will catch up with me. This snippet is something I really could have used last year when I was working with a WPF application.

#region $PROPNAME$ Property

public $PROPTYPE$ $PROPNAME$
{
    get { return ($PROPTYPE$) GetValue($PROPNAME$Property); }
    set { SetValue($PROPNAME$Property,value); }
}

public static readonly DependencyProperty $PROPNAME$Property = DependencyProperty.Register("$PROPNAME$", typeof($PROPTYPE$), typeof($DECLARING_TYPE$), new PropertyMetadata($DEF_VALUE$, On$PROPNAME$Changed));

private static void On$PROPNAME$Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    $DECLARING_TYPE$ $DECLARING_TYPE_var$ = d as $DECLARING_TYPE$;
    $END$
}

#endregion

[via Roy Osherove]

 

On a side-note, while trying to work out how to best format the snippet to look halfway good on a blog, I found this very useful site that does just that. With just a small adjustment to get wrapping to work in all browsers, it is good to go and simple to use.