Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugproof/08668a3fb26a9d06e211e5c442da9fc7 to your computer and use it in GitHub Desktop.
Save bugproof/08668a3fb26a9d06e211e5c442da9fc7 to your computer and use it in GitHub Desktop.
Read-only dependency property WPF snippet
private static readonly $dependencyProperty$Key $propertyName$PropertyKey = $dependencyProperty$.RegisterReadOnly(
nameof($propertyName$), typeof($propertyType$), typeof($containingType$), new PropertyMetadata(default($propertyType$)));
public static readonly $dependencyProperty$ $propertyName$Property = $propertyName$PropertyKey.DependencyProperty;
public $propertyType$ $propertyName$
{
get => ($propertyType$) GetValue($propertyName$Property);
protected set => SetValue($propertyName$PropertyKey, value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment