Oct 22, 2011 at 5:21 AM
Edited Oct 22, 2011 at 5:36 AM
I started digging through my WPF books in hope of finding some magic to help and I actually did find it.
It started from one "Digging Deeper" note in Adam Nathan's book which says that, in the case of data binding to plain .NET properties, as opposed to DPs, WPF uses reflection. However, if it exists, it will use ICustomTypeDescriptor interface. This interface:
is from .NET 1.x, 2.0 days and I wasn't familiar with it. Turns out it was also used when displaying classes in Windows Forms PropertyGrid and can act as the proxy to any class, exposing its properties in any way user wants. This article by Stephen Toub
in MSDN Magazine shows the example where class with fields is made to look like it has properties that Forms PropertyGrid can see (because Forms PropertyGrid doesn't reflect on fields):
So my question is: wouldn't it make sense to leverage this interface also in case of Extended WPF PropertyGrid?