How To Reference Nested Types In XAML?

|

This is actually an undocumented trick, but it really works:

namespace ReferenceNestedTypeDemo
{
    public class MyClass
    {
        public enum MyEnum { Value1, Value2, Value3 };
    }
}

<ComboBox>
  <
ComboBoxItem Tag="{x:Static app:MyClass+MyEnum.Value1}">Value 1</ComboBoxItem>
  <
ComboBoxItem Tag="{x:Static app:MyClass+MyEnum.Value2}">Value 2</ComboBoxItem>
</
ComboBox>

 

0 comments: