Silverlight Mouse clicking bug

Oystein Bjorke 10 year бұрын 0
This discussion was imported from CodePlex

Tech_Junkie wrote at 2012-09-27 17:14:

Dear Objo (or others who know the solution)

In my project I use three mousehandlers on the plotmodel that is linked to the plot. Somehow if I click very fast, or move my mouse during the clicking (then it happens quicker) silverlight crashes. I think it has to do with putting annotation lines in the plotmodel, and a minimal example that has this behaviour can be seen at: 

http://pastebin.com/MNezy8wj

In the final project there is more data and more happens in the mousehandlers apart from the adding of the annotations. But this is a minimal example that also shows the crash.

When I do not use my own mousehandlers, there is also a but of lag sometimes when clicking excessively or moving the mouse around during the clicking. Could it have something to do with internal timelag and not being able to call the handlers quick enough?


objo wrote at 2012-09-29 20:40:

thanks for creating the minimal example. I am not sure why your example crashes, but I see you are adding the same annotation instances to the model's Annotations collection multiple times! OxyPlot currently does not check this for you. I did some changes and the following version does not crash on my machine http://pastebin.com/8hb7EzZH


Tech_Junkie wrote at 2012-09-30 12:03:

Thank you for taking a look. This is very similar to what I do in my real project, I also check the axis for its inverse point to get the value to plot on. There I also clear the list of annotations before adding new ones I want to go render, because I also include a text and arrow annotation for the value. For this example I just set a fixed value, to make the code more readable, while it still crashed. 

I think that maybe the forwarding of the event and the GetAxesFromPoint(e.Positionout xaxis, out yaxis); method help the application from not crashing, but i'm not sure. But because I won't be working on this project anymore, I am not in a position to check if this will work or not. I have tipped a colleague who will take this over from me about this thread and hope / guess that he will take a look at it.