Last active
June 25, 2019 12:04
-
-
Save ButchersBoy/17dde09a8b4b30cd888a to your computer and use it in GitHub Desktop.
My Resharper Templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| These files are resharper llive templates for working with XAML. Invaluable if you building custom controls. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ); } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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