﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>Property Changed</Title>
			<Shortcut>PropChanged</Shortcut>
			<Description>Creates a WinUI dependency property with property changed callback</Description>
			<Author>Samuel</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>Property type</ToolTip>
					<Default>string</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>Property name</ToolTip>
					<Default>Description</Default>
				</Literal>
				<Literal>
					<ID>owner</ID>
					<ToolTip>Owner type</ToolTip>
					<Default>MyControl</Default>
				</Literal>
				<Literal>
					<ID>defaultValue</ID>
					<ToolTip>Default value</ToolTip>
					<Default>string.Empty</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp">
				<![CDATA[
public $type$ $property$
{
    get => ($type$)GetValue($property$Property);
    set => SetValue($property$Property, value);
}

public static readonly DependencyProperty $property$Property =
    DependencyProperty.Register(
        nameof($property$),
        typeof($type$),
        typeof($owner$),
        new PropertyMetadata($defaultValue$, On$property$Changed));

private static void On$property$Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    var control = ($owner$)d;
}

$end$
]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>