Does anybody know if it is possible to do databinding on an IValueConverter based class?
I have the following converter:
[ValueConversion(typeof(int), typeof(Article))]
public class LookupArticleConverter : FrameworkElement, IValueConverter {
public static readonly DependencyProperty ArticlesProperty = DependencyProperty.Register("Articles", typeof(IEnumerable<Article>), typeof(LookupArticleConverter));
public IEnumerable<Article> Articles
{
get { return (IEnumerable<Article>)GetValue(ArticlesProperty); }
set { SetValue(ArticlesProperty, value); }
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
...
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
...
}
}
It's purpose is to lookup an article in a list by its Id, and return that article.
However, I'd like to fill the Articles property by databinding a collection to it, like this:
<local:LookupArticleConverter Articles="{Binding Articles}" x:Key="LookupArticle"/>
But this doesn't seem to work. The setter method is never called. The source property contains an actual nonempty collection, so that's not the problem.
There's no error messages regarding binding in the output log, neither.
Any clues?