I've a CollectionViewSource
as ItemsSource
of my DataGrid
. In Window.Resources
I have this definition:
<CollectionViewSource x:Key="ItemsPoolCollectionView"
Source="{Binding Path=MyObservableCollection, Mode=OneWay}" />
now, I would like to produce the same definition from code, so I've done this:
Dim _cvs as CollectionViewSource = New CollectionViewSource
Dim bindSource = New Binding() With {
.Path = New PropertyPath("MyObservableCollection"),
.Mode = BindingMode.OneWay }
_cvs.SetValue(CollectionViewSource.SourceProperty, bindSource)
but I've this error on the last statement:
'System.Windows.Data.Binding' is not a valid value for property 'Source'
What's wrong? How can I accomplish this?