Blend 2012 and weird error

Blend2012

Last week, using Blend 2012 in a Windows Phone 8 Project caused a weird error. An error hard to know why it is happening and which sentence is the guilty.

The error says:

“Unable to cast object of type ‘System.Reflection.CustomAttributeData’ to type ‘System.ComponentModel.TypeConverterAttribute’

If you search on the Internet about this error you can find some webs talking about Update 2 of Visual Studio 2012 in WP8 projects but in my case the problema came from another spot.

I was working with DataTrigger and ChangePropertyAction in Windows Phone 8 using Blend 2012. From properties tab I put the Binding, the Value to compare, the property to modify and finally the value to assign.

In this case the property was Source from Image Control and Blend 2012 write in XAML this piece of code as follows:

<ec:DataTrigger Binding=”{Binding Path=Level}” Value=”Level1″>
<ec:ChangePropertyAction PropertyName=”Source”>
<ec:ChangePropertyAction.Value>
<Source>/Assets/Levels/logoGraduacio1stars.png”</Source>
</ec:ChangePropertyAction.Value>
</ec:ChangePropertyAction>
</ec:DataTrigger>

The famous error is below this line:

<Source>/Assets/Levels/logoGraduacio1stars.png”</Source>

 

The correct piece of code has to be:

<ec:DataTrigger Binding=”{Binding Path=Level}” Value=”Level1″>
<ec:ChangePropertyAction PropertyName=”Source”>
<ec:ChangePropertyAction.Value>
<BitmapImage UriSource=”/Assets/Levels/logoGraduacio1stars.png”></BitmapImage>
</ec:ChangePropertyAction.Value>
</ec:ChangePropertyAction>
</ec:DataTrigger>

Enjoy programming.

 

Advertisements

Deixa un comentari

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

WordPress.com Logo

Esteu comentant fent servir el compte WordPress.com. Log Out / Canvia )

Twitter picture

Esteu comentant fent servir el compte Twitter. Log Out / Canvia )

Facebook photo

Esteu comentant fent servir el compte Facebook. Log Out / Canvia )

Google+ photo

Esteu comentant fent servir el compte Google+. Log Out / Canvia )

Connecting to %s