Silverlight
I had to change a couple of properties to Dependency Properties in Silverlight/C# today. Driving home I thought it would be better to have code snippets so next time it would be easier.
I made two snippets:
propdepreg generated code:
public int MyProperty
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
public static DependencyProperty MyPropertyProperty = DependencyProperty.Register("MyProperty", typeof(int), typeof(dataviewcontrol), null);
The other snippet includes a PropertyChangedCallback method.
propdepregchanged generated code:
public int MyProperty
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
public static DependencyProperty MyPropertyProperty = DependencyProperty.Register("MyProperty", typeof(int), typeof(ClassNamePlaceholder), new PropertyMetadata(MyPropertyChanged));
private static void MyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
// insert your code here
}
Download the two files below. To install open the Code Snippets Manager (Ctrl-K, Ctrl-B) of Visual Studio, choose C# and your favorite folder and click "Import" to import both files.
