<chart:SfChart MouseMove="SfChart_MouseMove" MouseLeftButtonUp="SfChart_MouseLeftButtonUP">
<chart:SfChart.PrimaryAxis>
<chart:NumericalAxis />
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis />
</chart:SfChart.SecondaryAxis>
<chart:SfChart.Legend>
<chart:ChartLegend x:Name="legend" DockPosition="Floating" MouseLeftButtonDown="legend_MouseLeftButtonDown" OffsetX="200" CheckBoxVisibility="Visible"/>
</chart:SfChart.Legend>
<chart:LineSeries ItemsSource="{Binding Collection}" Label="Line Series" XBindingPath="XValue" YBindingPath="YValue"/>
</chart:SfChart>
|
private void SfChart_MouseMove(object sender, MouseEventArgs e)
{
var chart = sender as SfChart;
if (isDragable)
{
var _offsetX = e.GetPosition(chart).X;
var _offsetY = e.GetPosition(chart).Y;
(chart.Legend as ChartLegend).OffsetX = _offsetX -50;
(chart.Legend as ChartLegend).OffsetY = _offsetY;
}
if ((chart.Legend as ChartLegend).IsMouseOver)
{
if (Mouse.OverrideCursor == null)
Mouse.OverrideCursor = Cursors.Hand;
}
}
private void SfChart_MouseLeftButtonUP(object sender, MouseButtonEventArgs e)
{
isDragable = false;
}
private void legend_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
isDragable = true;
} |
Thank you for your help!