WPF Panel.Children vs Panel.InternalChildren - What's the Difference?

According to MSDN - Panel.InternalChildren Property :

Classes derived from Panel should use this property instead of Children for internal overrides like MeasureCore and ArrangeCore .


So this is really a two-part question:

  • If I create my own panel, FooPanel , which comes from Panel , I cannot override MeasureCore or ArrangeCore . I do not know why this statement exists even there. However, I can override MeasureOverride and ArrangeOverride . So, I am wondering if I still need to use the InternalChildren property for these two methods.

  • What is the real difference between the Children property and the InternalChildren property?

+8
wpf panel children
source share
2 answers
  • You would redefine MeasureOverride and ArrangeOverride, which should be a documentation error or intended for internal Microsoft employees. MeasureCore and ArrangeCore are sealed by FrameworkElement, so you cannot override them.

  • The Children property is publicly available and simply calls InternalChildren, which is protected. This way, either is probably safe, as the children will go into the course.

MSDN says otherwise ( http://msdn.microsoft.com/en-us/library/ms754152.aspx ), but the documentation is incorrect. (use a reflector to see that the children implementation just calls InternalChildren)

+9
source share

EDIT: As fixed by CodeNaked - MSDN docs are actually incorrect. Inner children and children are the same.


Children are just children who were added regularly, while InternalChildren includes children who were added through data binding (when the panel is an ItemsPanelTemplate)

"Children represent the child collection of elements that the Group consisting of. InternalChildren represents the contents of the children of the collection plus those elements generated by the data binding. Both consist of a UIElementCollection of children located inside the parent of the Group."

see http://msdn.microsoft.com/en-us/library/ms754152.aspx

+1
source share

All Articles