kelias Posted June 10, 2010 Report Share Posted June 10, 2010 When the user moves the mouse over the chart I would like a crosshair to appear and track with the mouse. (vertical and horizonal line that intersect at the current mouse location) This should only be on the chart portion and not on the legend or titles etc.. I assume I would use annotation's to accomplish this? Do you have a sample of this anywhere? Thanks, Quote Link to comment Share on other sites More sharing options...
kelias Posted June 10, 2010 Author Report Share Posted June 10, 2010 Nevermind got it working. Heres what I did: In the XAML I added two annotations for the horizontal and vertical lines. (note the binding, to span to the size of the container) <cfx:Chart.Extensions> <cfxAnnotation:Annotations x:Name="annotations"> <Line x:Name="lineH" Visibility="Visible" Fill="Black" Stroke="Black" X1="0" X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Canvas}},Path=Width}" /> <Line x:Name="lineV" Visibility="Visible" Fill="Black" Stroke="Black" Y1="0" Y2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Canvas}},Path=Height}" /> </cfxAnnotation:Annotations> </cfx:Chart.Extensions> C# Code private void OnChartMouseMove(object sender, MouseEventArgs e) { HitTestResults hitTest = chart1.HitTest(e.GetPosition(chart1)); if (!hitTest.IsInsidePlotArea) return; Axis axisX = chart1.AxisX; Axis axisY = chart1.AxisY; FrameworkElement parent = lineH.Parent as FrameworkElement; lineH.Y1 = e.GetPosition(parent).Y; lineH.Y2 = e.GetPosition(parent).Y; lineV.X1 = e.GetPosition(parent).X; lineV.X2 = e.GetPosition(parent).X; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.