I have developed an indicator that draws a set of buttons on the chart trader and I load one indicator onto each panel.
Sometimes, the sets of buttons can draw and stack properly on top each other.
Most of the times, the buttons do not draw for one or both indicators and the log shows the error "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread."
When this happens, I open up the properties of the indicator and discover that the Input Series under Data Series becomes "Close" instead of the instrument name.
To get both sets of buttons to show correctly, I need to press F5 many times to keep refreshing the chart until the error disappears.
I have tried adding delay to one of the indicators, so they do not load at the same time:
else if (State == State.Historical)
{
if (ChartControl != null)
{
ChartControl.Dispatcher.InvokeAsync(() =>
{
Thread.Sleep(1000); // Added this line
CreateWPFControls();
});
}
}
​
However, the above do not seem to resolve the issue.
May I ask what is causing the error and what can I do to resolve it?
Thank you very much for your assistance.

Comment