Silly gotcha when using sample data in Blend

I was working on a list box project and wanted to use Blend to edit my container styles when I was faced with the age old problem of providing Blend with some useful data. So I created a nice little collection class wrapping my target object and asked Blend to use it as a datasource, ensuring that the collection would initialise itself in its constructor. Hurray I had a nice design view with sample data. However, when I switched back to Visual Studio it complained that the resource xaml containing my datasource definition was invalid, the dreaded AEG error. After a great deal of head scratching I realised that somehow Blend had successfully added an x:Name attribute to the resource but my collection class does not derive from any Element and therefore does not have an x:Name. Once I realised that I (ahem) hacked a quick derive-from-user control onto the collection class and we’re up and running again. So watch out, just cause Blend doesn’t complain doesn’t mean it hasn’t generated some dodgy xaml.
Advertisements
This entry was posted in Silverlight. Bookmark the permalink.

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