I am writing a WPF chart and use Visuals for performance. The code looks like:
public class DrawingCanvas2 : Canvas
{
private List<Visual> _visuals = new List<Visual>();
protected override Visual GetVisualChild( int index ) { return _visuals[index]; }
protected override int VisualChildrenCount { get { return _visuals.Count; } }
public void AddVisual( Visual visual )
{
_visuals.Add( visual );
base.AddVisualChild( visual );
base.AddLogicalChild( visual );
}
}
Beside DrawingVisual
elements (line, text) I need a ComboBox
in the chart. So I tried this:
public DrawingCanvas2()
{
ComboBox box = new ComboBox();
AddVisual( box );
box.Width = 100;
box.Height = 30;
Canvas.SetLeft( box, 10 );
Canvas.SetTop( box, 10 );
}
but it does not work, there is no ComboBox displayed. What I am missing?