View previous topic :: View next topic |
Author |
Message |
GreyCloud
Joined: 13 Nov 2008 Posts: 19
|
Posted: Thu Jul 15, 2010 7:52 pm Post subject: Bind to an (extension) Method? |
|
|
Hi,
out of interest, why must i bind to a property in the designer and not a method? (seeing as in binding to a property i am just binding to the get method of the property?)
i ask since i tried to use an extension method for binding to an XElement.. [C# 4.0 still doesnt support extension properties - eg http://blogs.msdn.com/b/ericlippert/archive/2009/10/05/why-no-extension-properties.aspx]
Code: |
public static List<XElement> ChildNodes(this XElement element) {
return element.Elements().ToList();
}
|
clearly there are many work arounds to this problem but i was just wondering
David |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Jul 15, 2010 10:56 pm Post subject: |
|
|
VirtualTree uses reflection to bind to properties. Properties and methods are treated differently by reflection. While it would be technically possible to bind to a (parameterless) method via reflection it would complicate the binding code to deal with the two different mechanisms. Since extension methods are implemented quite differently to standard methods, binding to a standard method via reflection would probably not help here.
The workaround is to use programmatic binding for this cell. You can still use object binding for other rows/cells. See the help section "Mixing Programmatic Binding and Design Time Binding". _________________ Infralution Support |
|
Back to top |
|
|
|