私はデータグリッドを持っています。その ItemsSource は、ViewModel を介して ModelView の CompositeCollection にバインドされます。CompositeCollection は、2 つの ObservableCollection で構成されます。
グリッドの表示は問題ありません。コレクションを見ることができました。ただし、行の 1 つを編集しようとすると、「'EditItem' はこのビューでは許可されていません」というクラッシュ (NotSupportedException) が発生します。
行を編集可能にするにはどうすればよいですか? グリッドの各行を表す ModelViews を編集できる必要があります。
アイテムソースにバインドするために使用する CompositeCollection プロパティ コードは次のとおりです。 正確なコードを投稿することは許可されていないため、これは正確なコードではありませんが、コレクションの作成方法と同じロジックです。
public CompositeCollection ModelViewsCollection { get { CollectionContainer modelViewContainer;
CompositeCollection modelViewCollection = new CompositeCollection();
modelViewContainer= new CollectionContainer();
modelViewContainer.Collection= this.ModelViewCollection;
modelViewCollection .Add(modelViewContainer);
modelViewContainer= 新しい CollectionContainer(); modelViewContainer.Collection= this.ModelViewCollection2; modelViewCollection .Add(modelViewContainer);
return modelViewCollection;
}
}