Rectangular annotation and mouse events in WPF

Oct 19, 2012 at 5:27 PM

Hi,

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")

 

Thanks!

Coordinator
Oct 21, 2012 at 7:53 PM

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.

Oct 23, 2012 at 1:14 PM

Awesome, thanks! 

Oct 23, 2012 at 2:35 PM

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?

 

Thanks!

Oct 23, 2012 at 3:23 PM

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 };

chartingOxyPlot.Annotations.Add(la);

chartingOxyPlot.Annotations.Add((OxyPlot.Wpf.LineAnnotation)la);

Oct 23, 2012 at 5:56 PM

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