After a great deal of debugging with NO INFORMATION PROVIDED BY MICROSOFT in the exception details, I finally received a great idea from a fellow code projecter. I pulled out all forms from the view until it loaded then began slowly putting them back. I now have isolated the offending code. It sure would save time if the exception could point me to the form that was processed at the time of this exception!
So here is the view that is barfing..changed how the template is applied following an article here on CodeProject.
<UserControl x:Class="Servpro.Framework.ViewerModule.Views.MenuView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="580" d:DesignWidth="210">
<UserControl.Resources>
<Style TargetType="ListView">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock
removed="Transparent"
Foreground="Black"
FontSize="12"
Text="{Binding Path=CurrentEvent.EventTypeName, Mode=OneWay}" />
<TextBlock
removed="Transparent"
Foreground="Black"
FontSize="12"
Text="{Binding Path=CurrentEvent.EventMessage, Mode=OneWay}" />
<StackPanel Orientation="Horizontal">
<TextBlock
removed="Transparent"
Foreground="Black"
FontSize="8"
Text="{Binding Path=CurrentEvent.EventLoggedOn, Mode=OneWay}"
Margin="0,0,10,0" />
<TextBlock
removed="Transparent"
Foreground="Black"
FontSize="8"
Text="{Binding Path=CurrentEvent.Program, Mode=OneWay}" />
<TextBlock
removed="Transparent"
Foreground="Black"
FontSize="8"
Text=":" />
<TextBlock
removed="Transparent"
Foreground="Black"
FontSize="8"
Text="{Binding Path=CurrentEvent.Method, Mode=OneWay}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid Margin="4">
<ListView
ItemsSource="{Binding Path=EventList, Mode=OneWay}"
Height="568" VerticalAlignment="Top"
Width="201" HorizontalAlignment="Left"
Margin="4" >
<Border CornerRadius="11" />
<ListView.BorderBrush >
<SolidColorBrush Color="#99FFFFFF" Opacity="0" />
</ListView.BorderBrush>
<ListView.Background>
<SolidColorBrush Color="#99FFFFFF" Opacity="0"/>
</ListView.Background>
</ListView>
</Grid>
</UserControl>
The code behind hasn't changed from before .. injection of a view model and a public property to set the model in the DataContext. I found I had to change my order for setting DataContext. Now I get an exception
Add value to collection of type ItemCollection thre an exception. Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource. But I'm not putting anything in ItemCollection!
Ideas on how this is happening?