Well, a couple of days ago a coworker and I came across a very strange behaviour concerning Expression Blend while binding to a generic list of an interface. And we were able to reproduce the same behaviour in Visual Studion 2008 as well.

In our example ObservableCollection, where Mitarbeiter is the German word for employee. Sorry about the German throughout the example, but I am currently waiting to board my plane and I did not have enought time to reproduce the screenshot with a purely English example. Well, treat it as your first lesson in German. ;)

Anyway, so IMitarbeiter is the interface describing an employee and here is the important part: it is derived from another interface IPerson (where you are in luck, because German Person = English person. Great stuff, hugh?)

So basically the interface is:

C#:
  1. public interface IMitarbeiter : IPerson
  2. {
  3.   string Email { get; }
  4.   IArbeitsplatz Arbeitsplatz { get; }
  5. }

EMail = email (dugh) Arbeitsplatz = working space

And here is the definition for IPerson:

C#:
  1. public interface IPerson
  2. {
  3.   IPersonName Name { get; }
  4.   byte[] Bild { get; }
  5.   string Beschreibung { get; }
  6. }

Name = name (double dugh) Bild = picture Beschreibung = description

So. As I said the interface IMitarbeiter is now used to define a generic list ObservableCollection which we now want to bind to a WPF interface using Expression Blend. We do not worry about where this ObservableCollection comes from (since I know you are going to as: it come from some distant, well capsulated business tier, going through a GUI specific processing layer using MVP and blablabla... ;) ), we are stricktly concerned with interface matters.

All that is done by the developer is create this codebehind:

C#:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using System.Collections.ObjectModel;
  15. using System.Drawing;
  16.  
  17. public partial class MainForm : Window
  18. {
  19.   public ObservableCollection<IMitarbeiter> MitarbeiterCollection
  20.   {
  21.     get { return m_MitarbeiterCollection; }
  22.   }
  23.  
  24.   ...
  25.  
  26. }

So we are firing up Expression Blend and start doing the object binding, go to the "Create Data Template" Dialog and see this:

Create Data Template Dialog in Expression Blend with Bug

So we ONLY see the stuff defined in IMitarbeiter. No Fields coming from IPerson! Why that is is absolutely not clear. Most likely the deverloper of the code that does the reflection to analyse the interface did pass the wrong value that controlled the walking of the inheritance tree. The fun part is: This behaviour is totally reproducable in ASP.NET's databinding as well.

I have to emphasis, this is absolutely a GUI bug. When handcoding against the interface's properties everything works as expected.

I am sorry about this hurried post - but actually we started boarding and I am the last person sitting out her - and the nice lady behind the counter is starting to give me some nasty looks. Gotta go.