枚举依赖属性不与intellisense一起使用

时间:2012-06-23 19:25:17

标签: wpf xaml

我有以下UserControl

public partial class TestCtrl : UserControl
{
    public enum Alignments
    {
        HORIZONTAL,
        VERTICAL
    }

    public TestCtrl()
    {
        InitializeComponent();
    }

    public static DependencyProperty AlignmentProperty = DependencyProperty.Register(
    "Alignment",
    typeof(Alignments),
    typeof(TestCtrl),
    new PropertyMetadata(Alignments.HORIZONTAL));

    public Alignments Alignment
    {
        get
        {
            return (Alignments)GetValue(AlignmentProperty);
        }
        set
        {
            SetValue(AlignmentProperty, value);
        }
    }
}

该属性有效,但在xaml中使用该属性时,auto-complete不会检测该属性的可能值。

1 个答案:

答案 0 :(得分:1)

找到答案,根据this howto结果你需要使用依赖属性声明类外的枚举