我想实现自己的从 FrameworkElement 派生的控件,但未呈现添加的子元素。
我不知道为什么。
public class RangeSelection : FrameworkElement
{
private Thumb thumb = null;
#region Construction / Destruction
public RangeSelection()
{
this.thumb = new Thumb();
this.thumb.Width = 32.0;
this.thumb.Height = 32.0;
this.AddVisualChild(this.thumb);
}
#endregion
protected override Size MeasureOverride(Size availableSize)
{
this.thumb.Measure(availableSize);
return new Size(64.0, 64.0);
}
protected override Size ArrangeOverride(Size finalSize)
{
this.thumb.Arrange(new Rect(0, 0, 64.0, 64.0));
return base.ArrangeOverride(finalSize);
}
}