Metro Nuggets

Bitesized tidbits for building Modern (Metro) apps.

Binding To Anonymous Types

I was working on an app recently where an xml datasource was pulled in and I decided to use linq to parse the data to an anonymous types. The plan was to then bind that data to the listbox in my UI. The data got parsed correctly and I could see my anonymous type, but my UI was simply not being updated. So what was wrong?

The Solution

After a bit of bingling (yeah, it’s a word… honest), I found my solution in a StackOverflow question. It’s a very simple solution and basically involves putting one line of code into your AssemblyInfo.cs:

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

And that’s it.

I should point out that this isn’t limited to Windows Phone and would work if you had the same problem in normal Silverlight.

SL

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: