If you insert the snippet propdp, it doesn't use the nameof operator for the property name in the first parameter of the DepencendyProperty.Register method and it creates something like this:
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(MyContentControl), new PropertyMetadata(""));
and obviusly can be better if you use the operator nameof like in the next example:
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(nameof(Text), typeof(string), typeof(MyContentControl), new PropertyMetadata(""));
You can modify the code snippet following the next steps:
Open the file and change the definition of the macro from
public static readonly DependencyProperty $property$Property =
DependencyProperty.Register("$property$", typeof($type$), typeof($ownerclass$), new PropertyMetadata($defaultvalue$));
to
public static readonly DependencyProperty $property$Property =
DependencyProperty.Register(nameof($property$) , typeof($type$), typeof($ownerclass$), new PropertyMetadata($defaultvalue$));
and save (remember to open your text editor as an administrator).
Restart Visual Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With