gpt4 book ai didi

c# - 有没有办法在 MVVM 中自动创建 DependencyProperty

转载 作者:太空狗 更新时间:2023-10-29 23:58:48 25 4
gpt4 key购买 nike

更多的是可用性问题。我正在构建一个大型 MVVM 应用程序,我发现自己到处复制/修改这段代码:

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));

在 Visual Studio 中有没有一种方法可以使用快捷方式或其他方式生成此代码?我有 Resharper 和 VS 2015,但我找不到可以自动为我执行此操作的命令。

最佳答案

如果您使用 ReSharper,dependencyProperty 片段会生成它。在没有 ReSharper 的情况下,propdp 代码片段会创建相同的内容。

关于c# - 有没有办法在 MVVM 中自动创建 DependencyProperty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42691402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com