This project is read-only.

InvalidOperationException in databound ElementFlow when collection is changed

Sep 19, 2012 at 2:15 PM
Edited Sep 19, 2012 at 4:53 PM

I have ElementFlowContainer user control that contains ElementFlow from Showcase project.


<UserControl x:Class="Controls.ElementFlowContainer">
<-- Other controls (cut) -->
<Controls:ElementFlow x:Name="_elementFlow" 
ItemsSource="{Binding}" ItemTemplate="{DynamicResource 
TestDataTemplate}" SelectedIndex="3">
<-- Layout, Background, Camera settings (cut) -->


I have ObservableCollection<MediaRecord> that serves as DataContext of ElementFlow :


<Controls:ElementFlowContainer DataContext="{Binding 


MediaRecord has image property (byte[] Content) which i want to display. Here's template :


<DataTemplate x:Key="TestDataTemplate" 
DataType="{x:Type DAL:MediaRecord}">
<Border x:Name="ElementVisual" Background="White" 
BorderThickness="2" BorderBrush="#ff9e8028">
<Image Source="{Binding Content}" Stretch="Fill" />


All the stuff above is in ViewModel which is created by IoC container (MediaRecords property is null during initialization). When collection is filled with items I get


"InvalidOperationException '[Unknown]' property does 
not point to a DependencyObject in 
path "(0)[0].(1)[1].(2).(3)[0].(4)."


This error happens in RaisePropertyChanged in property setter :


public const string MediaRecordsPropertyName = 
public ObservableCollection<MediaRecord> MediaRecords
 get { return _mediaRecords; }
 set { if (_mediaRecords == value) { return; }
 _mediaRecords = value;
 RaisePropertyChanged(MediaRecordsPropertyName); // error here         


Any idea how to fix this?


Same collection is bound to another control, so i guess this issue is concurrency related. Fixed it quick-and-dirty by maintaining second copy of collection and binding to it, but maybe there is a better way?