According to MSDN - Panel.InternalChildren Property:
Classes that are derived from Panel should use this property, instead of the Children property, for internal overrides such as MeasureCore and ArrangeCore.
So, this is really a 2 part question:
If I create a Panel of my own, FooPanel
, which derives from Panel
, I can't seem to override MeasureCore
or ArrangeCore
. I'm not sure why that statement is even there. I can, however, override MeasureOverride
and ArrangeOverride
. So, I wonder if I still need to use the InternalChildren
property for these 2 methods.
What is the real difference between the Children
property and the InternalChildren
property?
You would override MeasureOverride and ArrangeOverride, that must be a mistake in the documentation, or intended for internal Microsoft employees. The MeasureCore and ArrangeCore are sealed by FrameworkElement, so you can't override them.
The Children property is public and simply calls InternalChildren, which is protected. So either is probably safe, since Children would get inlined.
MSDN says otherwise ( http://msdn.microsoft.com/en-us/library/ms754152.aspx) but the documentation is wrong. (use reflector to see that the implementation of Children simply calls InternalChildren)
EDIT: As CodeNaked corrected - MSDN docs are in fact incorrect. InternalChildren and Children are the same.
Using reflector, you can see the implementation of Children which is public UIElementCollection Children { get { return this.InternalChildren; } }
. So unless there is some voodoo going on, they are the same.
Children are just children that were added regularly, whereas InternalChildren includes children that were added through data binding (when the panel is the ItemsPanelTemplate)
"Children represents the child collection of elements that the Panel is comprised of. InternalChildren represents the content of the Children collection plus those members generated by data binding. Both consist of a UIElementCollection of child elements hosted within the parent Panel."
see http://msdn.microsoft.com/en-us/library/ms754152.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With