Skip to content

Instantly share code, notes, and snippets.

@ButchersBoy
Last active June 25, 2019 12:04
Show Gist options
  • Select an option

  • Save ButchersBoy/17dde09a8b4b30cd888a to your computer and use it in GitHub Desktop.

Select an option

Save ButchersBoy/17dde09a8b4b30cd888a to your computer and use it in GitHub Desktop.
My Resharper Templates
These files are resharper llive templates for working with XAML. Invaluable if you building custom controls.
private static readonly DependencyPropertyKey $propertyName$PropertyKey =
DependencyProperty.RegisterReadOnly(
"$propertyName$", typeof ($propertyType$), typeof ($containingType$),
new PropertyMetadata(default($propertyType$)));
public static readonly DependencyProperty $propertyName$Property =
$propertyName$PropertyKey.DependencyProperty;
public $propertyType$ $propertyName$
{
get { return ($propertyType$) GetValue($propertyName$Property ); }
private set { SetValue($propertyName$PropertyKey, value ); }
}
private static readonly DependencyPropertyKey $propertyName$PropertyKey =
DependencyProperty.RegisterReadOnly(
"$propertyName$", typeof ($propertyType$), typeof ($containingType$),
new PropertyMetadata(default($propertyType$), On$propertyName$Changed ) );
public static readonly DependencyProperty $propertyName$Property =
$propertyName$PropertyKey.DependencyProperty;
public $propertyType$ $propertyName$
{
get { return ($propertyType$) GetValue($propertyName$Property ); }
private set { SetValue($propertyName$PropertyKey, value ); }
}
public static readonly RoutedEvent $propertyName$ChangedEvent =
EventManager.RegisterRoutedEvent(
"$propertyName$Changed",
RoutingStrategy.$routingStrategy$,
typeof( RoutedPropertyChangedEventHandler<$propertyType$> ),
typeof($containingType$) );
public event RoutedPropertyChangedEventHandler<$propertyType$> $propertyName$Changed
{
add { AddHandler($propertyName$ChangedEvent, value ); }
remove { RemoveHandler($propertyName$ChangedEvent, value ); }
}
private static void On$propertyName$Changed(
DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var instance = ($containingType$)d;
var args = new RoutedPropertyChangedEventArgs<$propertyType$>(
($propertyType$) e.OldValue,
($propertyType$) e.NewValue )
{
RoutedEvent = $containingType$.$propertyName$ChangedEvent
};
instance.RaiseEvent( args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment