tags:

views:

918

answers:

2

In XAML if I am defining the Orientation property for a StackPanel, IntelliSense brings up the Orientation enum. If I'm defining my own control with a DependencyProperty based on an enum, is there a way to get IntelliSense to bring up the enum?

Enum:

public enum MyEnum { Foo, Bar }

DependencyProperty in control:

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

EDIT:

Giving the answer to "Daniel Pratt", because he pointed me in the right direction. I'd have preferred a code example.

To get this to work:

  1. Add the XmlnsDefinition attribute to AssemblyInfo.cs

    [assembly: XmlnsDefinition("http://schemas.your-company.com/wpf/", "YourNamespace")]

  2. In the XAML source where the control will be defined add an xmlns entry for it

    xmlns:control="http://schemas.your-company.com/wpf/"

  3. Then presto, you can add the control and IntelliSense will bring up the enum values

A: 

try something like this or use ReSharper

Joachim Kerschbaumer
A: 

See my answer to this question.

Daniel Pratt
Can you provide a code example?
Dylan