Rectangular annotation and mouse events in WPF

Oystein Bjorke 6 years ago 0
This discussion was imported from CodePlex

ChevyCP wrote at 2012-10-19 19:27:


Great work, 2 quick questions:

1 - Would it be possible to create the code to use the rectangular annotations in wpf 4.0 xaml instead of just in the c# code? 


2 - For mouse events on line annotations, can the functions be created in xaml or do those have to be done in code? (ie -MouseDown="LA_MouseDown")



objo wrote at 2012-10-21 21:53:

1. I checked in the missing annotation adapter classes. See WpfExamples / AnnotationDemo

2. No, I don't think this is possible to do in XAML. I have not the events in the WPF adapter classes. But you can subscribe to the event of the "InternalAnnotation" properties of the annotations.

ChevyCP wrote at 2012-10-23 15:14:

Awesome, thanks! 

ChevyCP wrote at 2012-10-23 16:35:

Now, if I create a line annotation in xaml and I want to add mouse events for it, is that possible?  It already has a mousedown/up/etc, but those are not the oxyplot events.  I need to create the annotation in xaml since I am binding the text and 'X' property to a data class and I don't think I can use .setbinding.  So, how can I attach oxyplot mouse events to an annotation created in xaml, or how can I create bindings in c and create the whole annotation in c?



ChevyCP wrote at 2012-10-23 17:23:

I should clarify that I can set bindings on OxyPlot.wpf.Annotations just not on OxyPlot.LineAnnotation items.  And since I can't convert them, I can't add them to my xaml created plot.  The last two lines of code fail and can't have .setbinding, so I'm at a loss as to add mouse events to a line annotation that has binded properties.


 var la = new LineAnnotation { Type = LineAnnotationType.Vertical, X = 4 };



ChevyCP wrote at 2012-10-23 19:56:

I should have dug around a bit more.  The internalannotation property did the trick.