wpf - 如何让 IntelliSense 在 XAML 中的自定义/用户控件上自动完成枚举?

标签 wpf xaml

这个问题在这里已经有了答案:




9年前关闭。




Possible Duplicate:
WPF: how to display enum property values in vs2008 xaml editor intellisense?



在 XAML 中,如果我为 StackPanel 定义 Orientation 属性,IntelliSense 会显示 Orientation 枚举。如果我使用基于枚举的 DependencyProperty 定义自己的控件,有没有办法让 IntelliSense 调出枚举?

枚举:
public enum MyEnum { Foo, Bar }

DependencyProperty 控制:
public static readonly DependencyProperty MyEnumValueProperty =
    DependencyProperty.Register(
        "MyEnumValue",
        typeof(MyEnum),
        typeof(MyControl),
        new UIPropertyMetadata());

public MyEnum MyEnumValue
{
    get { return (MyEnum)GetValue(MyEnumValueProperty); }
    set { SetValue(MyEnumValueProperty, value); }
}

编辑:

回答“丹尼尔普拉特”,因为他为我指明了正确的方向。我更喜欢代码示例。

要使其工作:
  • 将 XmlnsDefinition 属性添加到 AssemblyInfo.cs

    [程序集:XmlnsDefinition("http://schemas.your-company.com/wpf/ ", "YourNamespace")]
  • 在将定义控件的 XAML 源中为其添加一个 xmlns 条目

    xmlns:control="http://schemas.your-company.com/wpf/"
  • 然后快速,您可以添加控件,IntelliSense 将显示枚举值
  • 最佳答案

    尝试类似 this或使用 ReSharper

    关于wpf - 如何让 IntelliSense 在 XAML 中的自定义/用户控件上自动完成枚举?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/596089/

    相关文章:

    WPF RotateTransform DataTrigger

    c++ - 在 Windows.Foundation.IReference`1 <Windows.Foundation.DateTime> 中使用 UWP CalendarDatePicker 结果

    xaml - 如何将控件高度数据绑定(bind)到另一个控件的高度?

    c# - WPF 样式不适用于运行时(但适用于设计器)

    c# - Mahapps 减慢 WPF 应用程序

    wpf - 如何将ComboBox的内容垂直居中?

    c# - 使用c#在wpf的列表框中选择多个项目

    c# - 创建 UWP 应用程序时如何使用 C# 更改 image.source?

    xaml - 如何将一个元素并排放置?

    c# - 最大化系统托盘中的应用程序?