Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to automatically create DependencyProperty in MVVM

More of a usability question. I'm building a big MVVM application, and I find myself copying / modifying this piece of code all over the place:

public NodeKind Kind
{
    get { return (NodeKind)this.GetValue(KindProperty); }
    set { this.SetValue(KindProperty, value); }
}

public static readonly DependencyProperty KindProperty = DependencyProperty.Register(
        "Kind", typeof(NodeKind), typeof(DashboardNode));

Is there a way in Visual Studio to generate this code with a shortcut or something? I have Resharper and VS 2015, and I can't find the command that would automatically do that for me.

like image 401
edeboursetty Avatar asked Mar 09 '17 09:03

edeboursetty


2 Answers

If you use ReSharper the dependencyProperty snippet is generating this. Without ReSharper the propdp snippet is creating the same.

like image 163
Tóth Tibor Avatar answered Oct 19 '22 17:10

Tóth Tibor


There's the propdp snippet. Just type propdp and press TAB twice. A similar snippet exists for attached properties as well: propa

like image 6
Adi Lester Avatar answered Oct 19 '22 18:10

Adi Lester