if (AttachedTo != null)
{
marketData = new MarketData(AttachedTo.Instrument);
marketData.Update += OnMarketData;
}
The problem is, "AttachedTo" is always null when you first place the drawing object on the chart. Once you refresh the chart, it runs fine.
I believe the problem is that all the States are run/handled before the object is actually placed onto the chart. Thus, AttachedTo is null, thus it never adds the event handler. When you refresh the chart, it's already attached, so it works fine.
Is there a better place to add the event handler other than OnStateChange()? In OnRender() (not liking this option)? OnMouseDown()?
Thank you
Comment