Reputation: 25686
I have a collection ObservableCollection<Foo>
, and I want to bind this to a property in a custom controller of type ObservableCollection<object>
. However, the bound value never reaches the PropertyCallback, and is hence never set.
Is there a clever way to achieve this binding? I could create an IValueConverter that converts from ObservableCollection<Foo>
to ObservableCollection<object>
, but that gives new problems..
Upvotes: 1
Views: 409
Reputation: 4157
I don't think there is a beautiful way of achieving this. You might want to look into Covariance and Contravariance (.Net 4), but it won't work for your object example.
Upvotes: 0
Reputation: 36775
As far as I know, there is no automatic conversion. Writing a ValueConverter is an option.
If you have often the need for this specific conversion, maybe a TypeConverter can do what you need. After creating, declare it with the TypeConverterAttribute, then in bindings automatic conversion will be done.
Upvotes: 1