Chart for WinRT
Mouse Interaction with ChartPanel

The ChartPanelObject has mouse interaction support. The ChartPanelAction enumeration specifies possible action for the chart panel objects. The ChartPanelAction enumeration includes the following members:

Member name

Description

None

No action.

MouseMove

Follow mouse.

LeftMouseButtonDrag

Can be dragged with left mouse button.

RightMouseButtonDrag

Can be dragged with right mouse button.

Using the ChartPanelObject.Action property, you can make a draggable element or an element that follows the mouse pointer. For example, adding Action to the previous sample we get the marker that can be moved by a user.

XAML Markup
Copy Code
 <!-- vertical line -->
   <Chart:ChartPanelObject DataPoint="0,NaN" VerticalAlignment="Stretch"
      Action="LeftMouseButtonDrag" >
     <Border BorderBrush="Red" BorderThickness="3,0,0,0"
Margin="-1.5,0,0,0" />
   </Chart:ChartPanelObject>

Using data binding it's easy to add a label that shows the current coordinate:
   <!-- vertical line with coordinate label -->
   <Chart:ChartPanelObject x:Name="xmarker" DataPoint="0,NaN"
VerticalAlignment="Stretch"
       Action="LeftMouseButtonDrag">
     <Border BorderBrush="Red" BorderThickness="3,0,0,0"
Margin="-1.5,0,0,0" >
       <TextBlock
         Text="{Binding RelativeSource={RelativeSource Self},
         Path=Parent.Parent.DataPoint.X,StringFormat='x=0.0;x=-0.0'}" />
     </Border>
   </Chart:ChartPanelObject>

  The property ChartPanelObject.Attach allows you to stick the possible positions of the element to the nearest data point. It can be attached to a single coordinate(X or Y) or to both coordinates(XY).

 

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback