I am dynamically adding custom controls in Silverlight 2 but they are not visible. However, on examining the visual tree in Silverlight Spy I note that their visibility property is Visible and toggling it to Collapsed and back to Visible causes the controls to become visible.
What might I be doing wrong? Any ideas on what I should look for to resolve this?
I’ve been able to solve the problem, which occurred when I was dynamically adding time periods to a timeline.
The controls I’m dynamically adding, to a canvas, have the following structure.
The dimensions of the RectangleGeometry depend on three inputs, the date and time ranges of the timeline bar and timeline item (what I’m adding) and the dimensions of the bar (canvas).
The following method is called when any of the BarRange, ItemRange or BarSize properties of the object are set.
This caused the drawing problem mentioned in my question and the solution was to add
immediately after setting ribbonItemBackground.Rect.