ComponentOne Chart for WPF and Silverlight
Chart for WPF and Silverlight / Chart Features / Markers Labels / Mouse Interaction Chart Panel
In This Topic
    Mouse Interaction Chart Panel
    In This Topic

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

     

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

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

    Using data binding it's easy to add label that shows the current coordinate:

    XAML
    Copy Code
      <!-- vertical line with coordinate label -->
       <c1chart: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>
       </c1chart:ChartPanelObject>
    

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

     

    See Also