FluidKit.Showcase プロジェクトの ElementFlow を含む ElementFlowContainer ユーザー コントロールがあります。
<UserControl x:Class="Controls.ElementFlowContainer">
<Grid>
<-- Other controls (cut) -->
<Controls:ElementFlow x:Name="_elementFlow" ItemsSource="{Binding}" ItemTemplate="{DynamicResource TestDataTemplate}" SelectedIndex="3">
<-- Layout, Background, Camera settings (cut) -->
</Controls:ElementFlow>
</Grid>
</UserControl>
ElementFlow の DataContext として機能する ObservableCollection があります。
<Controls:ElementFlowContainer DataContext="{Binding MediaRecords}"/>
MediaRecord には、表示したい画像プロパティ (byte[] Content) があります。テンプレートは次のとおりです。
<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" />
</Border>
</DataTemplate>
上記のものはすべて、IoC コンテナーによって作成された ViewModel にあります (MediaRecords プロパティは初期化中に null になります)。コレクションがアイテムでいっぱいになったとき
"InvalidOperationException '[Unknown]' property does not point to a DependencyObject in
path "(0)[0].(1)[1].(2).(3)[0].(4)."
このエラーは、プロパティ セッターの RaisePropertyChanged で発生します。
public const string MediaRecordsPropertyName = "MediaRecords";
public ObservableCollection<MediaRecord> MediaRecords
{
get { return _mediaRecords; }
set
{ if (_mediaRecords == value) { return; } _mediaRecords = value;
RaisePropertyChanged(MediaRecordsPropertyName); // error here
}
}
これを修正する方法はありますか?
edit
同じコレクションが別のコントロールにバインドされているため、この問題は同時実行に関連していると思います。コレクションの 2 番目のコピーを保持し、それにバインドすることで手早く修正しましたが、もっと良い方法があるのではないでしょうか?