Hi All,
I'm struggling a bit. If I have classes as below:
public static class ClassName
{
...attached DP called 'ChildObjects', of type ChildCollection....
}
public class ChildCollection : ObservableCollection<child>
{
}
</child>
I can add an attached dependency property definition to ClassName, of type ChildCollection, allowing me to do the below:
<grid>
<classname.childobjects>
<childcollection>
<child someproperty="{Binding Etc}" />
<child someproperty="{Binding Etc}" />
</childcollection>
<classname.childobjects>
<grid></grid></classname.childobjects></classname.childobjects></grid>
This works great - Child objects are derived from FrameworkElement and therefore have a datacontext. The only problem is ChildCollection - it is not a framework element therefore it means that it's not in the logical tree, so bindings on the Child objects don't work - let alone using things like 'FindAncestor'.
Is there a standard way to deal with this? I've looked for 'FrameworkElementCollection' that would add the children to the logical tree but with no luck. Before I dive into creating one, I would like to know if I'm missing something obvious!
Thanks in advance,
Dave