I'm trying to use a nested type in my ObjectDataSource a la this article. It doesn't seem to be working for me.
<ObjectDataProvider x:Key="myProvider" ObjectType="{x:Type local:OutsideClass+InsideClass}" MethodName="GetObjects" />
I'm trying to use a nested type in my ObjectDataSource a la this article. It doesn't seem to be working for me.
<ObjectDataProvider x:Key="myProvider" ObjectType="{x:Type local:OutsideClass+InsideClass}" MethodName="GetObjects" />
This is a known issue in VS 2008 and beyond. Microsoft's official position is that you shouldn't be doing this:
Whilst the XAML you are writing is clearly legal, works at runtime, and loads in correctly in Expression Blend, we do not currently believe that use of and access to nested classes from Markup Extensions is very common in application building.
One way to work around x:Type
references to nested types is to define a new markup extension and use it instead of the x:Type
markup extension. I posted information about one such, including source for the Type2Extension
class, in this answer.
The Type2Extension
will not produce designer errors like the TypeExtension
does. Perhaps this will not occur in VS 2010.
The only caveat is that the original TypeExtension
you use with {x:Type
typename}
is a little more robust than Type2Extension
(e.g., checking if arguments are null and throwing exceptions).