【发布时间】:2016-02-15 13:33:11
【问题描述】:
当您使用 propdp 代码 sn-p 创建依赖属性时,它不会为您提供创建依赖属性的类的正确名称,并且您ve 像在下一个示例中那样手动键入它:
namespace YourApp.Controls
{
public sealed class YourButton : Control
{
public YourButton()
{
this.DefaultStyleKey = typeof(YourButton);
}
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(ownerclass), new PropertyMetadata(0));
}
}
我不希望 ownerclass 作为默认值,在这种情况下我希望 YourButton。
如何修改代码 sn-p 以提出正确的名称?
【问题讨论】:
标签: c# visual-studio visual-studio-2015 code-snippets