-
Shortcut
-
propds
-
Description
-
Code snippet for a property using DependencyProperty as the backing store and a Handler for the DependencyPropertyChanged event
-
Language
-
csharp
-
Types
-
Expansion
-
Author
-
Fons Sonnemans
-
Upload on
-
11-12-2013 14:30:27
-
Downloads
-
2603
ID
|
ToolTip
|
Default
|
type
|
Property Type
|
object
|
property
|
Property Name
|
MyProperty
|
defaultvalue
|
The default value for this property.
|
null
|
ownerclass
|
The owning class of this Property. Typically the class that it is declared in.
|
ClassNamePlaceholder
|
#region $property$ Dependency Property
/// <summary>
/// Get or Sets the $property$ dependency property.
/// </summary>
public $type$ $property$
{
get { return ($type$)GetValue($property$Property); }
set { SetValue($property$Property, value); }
}
/// <summary>
/// Identifies the $property$ dependency property. This enables animation, styling, binding, etc...
/// </summary>
public static readonly DependencyProperty $property$Property =
DependencyProperty.Register("$property$",
typeof($type$),
typeof($ownerclass$),
new PropertyMetadata($defaultvalue$, On$property$PropertyChanged));
/// <summary>
/// $property$ changed handler.
/// </summary>
/// <param name="d">$ownerclass$ that changed its $property$.</param>
/// <param name="e">DependencyPropertyChangedEventArgs.</param>
private static void On$property$PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var source = d as $ownerclass$;
if (source != null)
{
var value = ($type$)e.NewValue;
//TODO: Handle new value.
}
}
#endregion $property$ Dependency Property
$end$