LINQPad Controls don't call the ToDump methods of their children when dumped.
Not 100% sure that's what's happening or if it is intentional, or if I should be doing this another way...
A simple example:
void Main() { var a = new RangeContainer(50); a.Dump("A"); var b = new RangeContainer(50); var bDiv = new Div(b); bDiv.Dump("B"); } public class RangeContainer : Control { public Label label; public RangeControl range; public RangeContainer(int value) { label = new Label(value.ToString()); range = new RangeControl(0, 100, value); range.ValueInput += (s, a) => { label.Text = range.Value.ToString(); }; } object ToDump() => new Div(this.range, this.label); }
'A' appears and functions as expected
'B' has no output aside from the Dump heading
Comments
The simplest way to accomplish this to add the child controls to
RangeControl
'sVisualTree
:You can add controls to the protected
VisualTree
either in the constructor (as above) or in theOnRendering
method.Another approach is to base
RangeContainer
onDiv
instead ofControl
. You'll then be able to use the div'sChildren
property which will act as a synonym forVisualTree
:The first approach provides better decoupling in that it keeps the child controls hidden, preventing consumers of your
RangeControl
from knowing about or accessing its internal implementation.