With the following resource definition
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="AccountTypeValues">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="domain:Account+AccountType" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
the designer complains that “Type ‘Account+AccountType’ was not found.” However, the nested type exists and code complies and runs without a problem. Since the designer thinks the XAML is incorrect, it won’t display a graphical rendition of the XAML.
What do I need to do to get the designer to recognize Account+AccountType as valid? I’d really like the visual part of the designer to work.
Thank you,
Ben
It looks like this is a known bug in Visual Studio. From http://social.msdn.microsoft.com/forums/en-US/wpf/thread/12f3e120-e217-4eee-ab49-490b70031806/:
See also http://connect.microsoft.com/VisualStudio/feedback/details/361509/xaml-designer-cannot-handle-typename-with-nested-classes.
You could create a static property that calls
Enum.GetValues(typeof(Account.AccountType))and bind to that instead of using anObjectDataProvider. Or, if you control the types, you could move the enum outside the class.