【发布时间】:2013-09-05 12:12:28
【问题描述】:
说明
如果您为 UserControl 声明 EasingMode 的公共属性,则它不会显示在 Visual Studio 的属性中。 这是一种奇怪的行为,仅适用于 EasingMode,不适用于其他自定义属性。
问题
如果你有 EasingMode 的属性,它可以在 XAML 中使用并且是有效的属性。但我需要从 Visual Studio 中的 Properties 访问此属性。 来自简单枚举的简单公共属性必须像其他的一样在设计时可访问,但它不适用于 EasingMode,仅适用于 EasingMode
问题
我知道我可以直接从代码或 XAML 中更改属性的值,但是
- 我需要找出为什么这个属性会出现这种奇怪的行为。
- 如何解决这个问题?显示此枚举属性的解决方案是什么 来到 Visual Studio 的设计时的属性面板?
示例
看看这个例子
[Bindable(true)]
[Browsable(true)]
[Category("TEST")]
public EasingMode A1
{
get { return (EasingMode)this.GetValue(A1Property); }
set { this.SetValue(A1Property, value); }
}
public static readonly DependencyProperty A1Property = DependencyProperty.Register("A1", typeof(EasingMode), typeof(UserControl1));
[Bindable(true)]
[Browsable(true)]
[Category("TEST")]
public MessageBoxButton A2
{
get { return (MessageBoxButton)this.GetValue(A2Property); }
set { this.SetValue(A2Property, value); }
}
public static readonly DependencyProperty A2Property = DependencyProperty.Register("A2", typeof(MessageBoxButton), typeof(UserControl1));
A1 和 A2 是来自简单枚举的简单属性,但 A1 不会出现在 Visual Studio 的 Properties 面板中。测试它并找出它并帮助我:)
【问题讨论】:
标签: c# wpf xaml wpf-controls