I've a CollectionViewSource as ItemsSource of my DataGrid...on Window.Resources I've this definition:
<CollectionViewSource x:Key="ItemsPoolCollectionView"
Source="{Binding Path=MyObservableCollection, Mode=OneWay}" />
now, I would do 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 last statement: "'System.Windows.Data.Binding' is not a valid value for property 'Source'"
What's wrong? How can I do?
The CollectionViewSource don't have the "SetBinding" method..why?