Created
December 30, 2016 04:52
-
-
Save naotaco/befb8829fcbd25c1edb04c9f5fe14dde to your computer and use it in GitHub Desktop.
A snippet to create bindable property on VisualStudio
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Property</Title> | |
<Shortcut>pp</Shortcut> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>name</ID> | |
<Default>PropertyName</Default> | |
</Literal> | |
<Literal> | |
<ID>propType</ID> | |
<Default>PropertyType</Default> | |
</Literal> | |
<Literal> | |
<ID>controlType</ID> | |
<Default>YourControlType</Default> | |
</Literal> | |
</Declarations> | |
<Code Language="CSharp"> | |
public $propType$ $name$ | |
{ | |
get { return ($propType$)GetValue($name$Property); } | |
set { SetValue($name$Property, value); } | |
} | |
public static readonly DependencyProperty $name$Property = DependencyProperty.Register( | |
nameof($name$), | |
typeof($propType$), | |
typeof($controlType$), | |
new PropertyMetadata(0, new PropertyChangedCallback(On$name$Changed))); | |
private static void On$name$Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
(d as $controlType$).$name$ = ($propType$)e.NewValue; | |
} | |
</Code> | |
</Snippet> | |
</CodeSnippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment