私は私のCollectionViewSource
ようItemsSource
ですDataGrid
。私はこのWindow.Resources
定義を持っています:
<CollectionViewSource x:Key="ItemsPoolCollectionView"
Source="{Binding Path=MyObservableCollection, Mode=OneWay}" />
今、コードから同じ定義を作成したいので、これを行いました:
Dim _cvs as CollectionViewSource = New CollectionViewSource
Dim bindSource = New Binding() With {
.Path = New PropertyPath("MyObservableCollection"),
.Mode = BindingMode.OneWay }
_cvs.SetValue(CollectionViewSource.SourceProperty, bindSource)
しかし、最後のステートメントで次のエラーが発生しました。
'System.Windows.Data.Binding' is not a valid value for property 'Source'
どうしたの?どうすればこれを達成できますか?