views:

433

answers:

1

Does anyone know if you can use data binding with anonymous types in Silverlight 4? I know you can't in previous versions of silverlight, you can only databind to public class properties and anonymous type properties are internal.

Just wondering if anyone has tried it in silverlight 4?

Thanks in advanced

+9  A: 

You can... If you expose your internals.

Place this in your AssemblyInfo.cs.

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("System.Windows")]

Jason Jarrett
+1 That's rather clever.
Rangoric
Im going to have to try this
Anthony
Very cool! - This is actually the correct answer.
Rashack
And btw. this works in Silverlight 3 as well.
Rashack
Yup, I was able to get it to work as well. Thanks
Anthony
If you want to use things like Datagrid sorting you need to also include the [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("System.Windows.Data")] other wise you get a nasty security exception.
Anthony
Confirmed this works on Windows-Phone-7 too. Yay!
Matt Lacey