Silverlight 4 is crashing on me. The Just-In-Time Debugger says:
An unhandled exception ('Unhandled Error in Silverlight Application')
Code: 4004
Category: ManagedRuntimeError
Message: System.Windows.Markup.XamlparseException: [Line: 0 Position: 0]
I bind a listbox to a collection of 20 (or so) items. the collection loads fine and binds correctly. However, when I scroll to the bottom of the collection and then try to scroll back up silverlight crashes.
The error only occurs when I include a contentcontrol, contentpresenter, or an image control within my Item Template. For instance, If I set the 'InnerBorder' height to 100 and remove the content control silverlight will not crash. Furthermore The {Binding Visual} is a image defined on the item's view model.
Here is my code.
<Border HorizontalAlignment="Left"
Margin="2"
Padding="0">
<Controls:Expander ExpandDirection="Right"
Header="Templates">
<ListBox UseLayoutRounding="False"
SelectedItem="{Binding SelectedTemplate, Mode=TwoWay}"
Margin="4"
ItemsSource="{Binding Templates}"
ScrollViewer.VerticalScrollBarVisibility="Visible"
Width="250">
<ListBox.ItemTemplate>
<DataTemplate>
<Border Style="{StaticResource InnerBorder}"
Width="200"
Margin="4">
<ToolTipService.ToolTip>
<ToolTip Content="{Binding Description}" />
</ToolTipService.ToolTip>
<StackPanel Orientation="Vertical"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<ContentControl Content="{Binding Visual}"
MaxWidth="100" />
<TextBlock Text="{Binding Name}"
HorizontalAlignment="Center" />
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Controls:Expander>
Im totally lost. Any help would be greatly appreciated.