25

Is there any way to speed up creating dependency properties in Visual Studio? Like some template or refactoring option that will make dependency property out of normal one. Anything. I create a lot of dependency properties right now.

Pang
  • 9,564
  • 146
  • 81
  • 122
Rasto
  • 17,204
  • 47
  • 154
  • 245

5 Answers5

55

The code snippet for DPs is propdp, enter that and hit tab twice, then cycle through the fields with tab and fill them in.

H.B.
  • 166,899
  • 29
  • 327
  • 400
18

New(ish) versions of ReSharper

Newer versions of ReSharper come with the dependencyProperty snippet built in. So start typing "dependencyProperty" and it should pop up as an option for you to select (with the tab key).

In my opinion, this option is preferable because it comes with better defaults and formatting.


Old versions of ReSharper

If you're using an old ReSharper but still want to use Visual Studio's dependency property code snippet (without downloading anything), type PROPDP in all caps and then hit tab once.

IntelliSense will come up with "No suggestions" but insert the code snippet anyway.

Pang
  • 9,564
  • 146
  • 81
  • 122
Zach Olivare
  • 3,805
  • 3
  • 32
  • 45
7

As a side note, (and someone correct me if I'm wrong please!).

If you're using ReSharper, it overrides the default snippet/templating system and doesn't have a propdp equivalent as shipped.

I found a ReSharper propdp snippet here.

ocodo
  • 29,401
  • 18
  • 105
  • 117
0

I have, and still use these 5 dependency snippets which will add reference or value dependencies as selected. They were created for Silverlight (it was hot at the time, you youngins) but the code they lay down works in WPF and Visual Studio 2017.

Helpful Silverlight Snippets

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
0

I want to note that at the current time it is better to use https://github.com/HavenDV/DependencyPropertyGenerator, the code will be extremely simple:

[DependencyProperty<int>("MyProperty")]
public partial class MyControl : UserControl
{
}
Konstantin S.
  • 1,307
  • 14
  • 19