XAML error – System.Windows.Baml2006.TypeConverterMarkupExtension

Notice, if you will, this itty bitty block of code:

<ListBox Name="FilesList" ItemsSource="{Binding FileList}" Width="100%">
 <ListBox.ItemTemplate>
  <DataTemplate>
   <TextBlock Text="{Binding}" />
  </DataTemplate>
 </ListBox.ItemTemplate>
</ListBox>

While attempting to databind a custom collection class to a ListBox, I encountered an oddly named exception:

XamlParseException occurred
Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.

What the heck is Baml2006?

Anyway, here is the offending line:

<ListBox Name="FilesList" ItemsSource="{Binding FileList}" Width="100%">

Guess which part is the problem? The ‘Width=”100%”‘ part. When I changed it to read ‘Width=”350″‘, the error went away. No worries, but a more helpful error message would have been nice.

I’ve also received the “BAML” error where there are other invalid characters in a property value. So don’t put those invalid characters in property fields, kids – that’s bad.

Advertisements
  1. #1 by Vonziz on March 7, 2011 - 2:20 pm

    Hi,

    Width of your listbox can’t be in % in xaml langage, that’s why you’ve got this error.

    ++

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: