//图像加载
void Chart_Loaded(object sender, RoutedEventArgs e)
{
var plotAreaPanel = this.radChart.DefaultView.ChartArea.ChildrenOfType<ClipPanel>().FirstOrDefault();
plotAreaPanel.MouseEnter += this.OnPlotAreaPanelMouseEnter;
plotAreaPanel.MouseMove += this.OnPlotAreaPanelMouseMove;
plotAreaPanel.MouseLeave += this.OnPlotAreaPanelMouseLeave;
} //进入--添加GridLine
private void OnPlotAreaPanelMouseEnter(object sender, MouseEventArgs e)
{
if (null != xGridLine && null != yGridLine)
{
xGridLine = new CustomGridLine();
yGridLine = new CustomGridLine(); this.radChart.DefaultView.ChartArea.Annotations.Add(xGridLine);
this.radChart.DefaultView.ChartArea.Annotations.Add(yGridLine);
}
else
{
this.radChart.DefaultView.ChartArea.Annotations.Add(xGridLine);
this.radChart.DefaultView.ChartArea.Annotations.Add(yGridLine);
}
} //移动,实时跟踪
private void OnPlotAreaPanelMouseMove(object sender, MouseEventArgs e)
{
var plotAreaPanel = sender as ClipPanel;
var position = e.GetPosition(plotAreaPanel); var x = this.radChart.DefaultView.ChartArea.AxisX.ConvertPhysicalUnitsToData(position.X);
var y = this.radChart.DefaultView.ChartArea.AxisY.ConvertPhysicalUnitsToData(position.Y); //十字线赋值
xGridLine.XIntercept = x;
yGridLine.YIntercept = y; this.textX.Text = string.Format("X: {0:N3}", x);
this.textY.Text = string.Format("Y: {0:N3}", y);
} //移出-->移除GridLine
private void OnPlotAreaPanelMouseLeave(object sender, MouseEventArgs e)
{
this.radChart.DefaultView.ChartArea.Annotations.Remove(xGridLine);
this.radChart.DefaultView.ChartArea.Annotations.Remove(yGridLine);
}

这个事件稍一改动,就可以有圈选的功效

(这张图就不搞成动态gif了)

换汤不换药,源码过一遍就明白了

//进入
private void OnPlotAreaPanelMouseEnter(object sender, MouseEventArgs e)
{
if (null != mz)
{
mz = new MarkedZone();
mz.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xCC, 0x00));
this.radChart.DefaultView.ChartArea.Annotations.Add(mz);
}
else
{
this.radChart.DefaultView.ChartArea.Annotations.Add(mz);
}
} //移动
private void OnPlotAreaPanelMouseMove(object sender, MouseEventArgs e)
{
var plotAreaPanel = sender as ClipPanel;
var position = e.GetPosition(plotAreaPanel); var x = this.radChart.DefaultView.ChartArea.AxisX.ConvertPhysicalUnitsToData(position.X);
var y = this.radChart.DefaultView.ChartArea.AxisY.ConvertPhysicalUnitsToData(position.Y); mz.StartX = 0;  //可自定义,设置初始值,本次案例不做安排
mz.EndX = x;   
mz.StartY = 0;  
mz.EndY = y;    this.textX.Text = string.Format("X: {0:N3}", x);
this.textY.Text = string.Format("Y: {0:N3}", y);
} //移出
private void OnPlotAreaPanelMouseLeave(object sender, MouseEventArgs e)
{
this.radChart.DefaultView.ChartArea.Annotations.Remove(mz);
}

原文链接:http://www.telerik.com/help/silverlight/radchart-howto-create-location-crosshair-for-radchart.html

Silverlight RadChart :创建十字定位&圈选的更多相关文章

  1. HTML <select> 标签 创建单选或多选菜单

    所有主流浏览器都支持 <select> 标签. select 元素可创建单选或多选菜单. <select&> 元素中的 <option> 标签用于定义列表中 ...

  2. Silverlight 之 创建

          Silverlight 项目文件是您可以使用不同工具来创建和编辑的文本文件.例如,可以使用 Visual Studio 2010 以及 Expression Blend 来创建 Silve ...

  3. QT 创建一个具有复选功能的下拉列表控件

    最近研究了好多东西,前两天突然想做一个具有复选功能的下拉列表框.然后在网上"学习"了很久之后,终于发现了一个可以用的,特地发出来记录一下. 一.第一步肯定是先创建一个PROJECT ...

  4. C++第四十三篇 -- VS2017创建控制台程序勾选MFC类库

    用VS2017创建EXE带MFC类库方法 1. File --> New --> Project 2. Windows桌面向导 3. 勾选MFC类库 4. 创建成功 如果项目编译出错 1. ...

  5. Silverlight 动态创建Enum

    private Type CreateEnum() { List<string> lists = new List<string>(); lists.Add("男&q ...

  6. 使用Visual Studio 2010 创建简单的Silverlight应用程序

    使用Visual Studio 2010 创建简单的Silverlight应用程序 Silverlight是创建动态的引人的RIAs(Rich Internet Application)的新方法.这里 ...

  7. iOS iOS9.0 的CoreLocation定位

    一.简介 iOS9.0如果当前处于前台授权状态,默认是不可以后台获取用户位置. 如果在前台授权下,让其能获取到后台定位,该怎么办 可以设置以下属性为YES,就可以继续获取后台位置,但是会出现蓝条 使用 ...

  8. ArcGIS API for Silverlight开发入门

    你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我 都没关系.但你不能否认3G是一种趋势,最终我们每个人都会被包裹在3G网络中.1100也不是一成不变,没准哪天为了打击 ...

  9. QT中静态库的生成与使用——创建共享库代码,附例子

    一. 静态库的生成    1. 测试目录: lib    2. 源码文件名: mywindow.h, mywindow.cpp, 类MyWindow继承于QPushButton, 并将文字设置为&qu ...

随机推荐

  1. python 中的高级函数map()

    map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回. 例如,对于list [1, 2 ...

  2. 作业七:团队项目——Alpha版本冲刺阶段009

    今日安排:组内成员讨论 今日进度:组内成员讨论分工细节以及可能遇到的问题,并提出解决方案

  3. linux系统下yum 安装mysql的方法

    菜鸟一个,记录下yum 安装mysql的方法,给需要的朋友也做个参考吧. 弄了个新vps,想安装最新版的mysql,网上查了相关资料,记录如下: 1.安装查看有没有安装过:          yum ...

  4. Java第六次作业修改版

    import java.util.ArrayList; import java.util.Collections; import java.util.Random; public class Draw ...

  5. Android开源框架:Universal-Image-Loader解析(二)MemoryCache

  6. php数组常见的几种遍历方法

    1.foreach遍历 $arr[] = array('first'=>green,'second'=>'yellow','third'=>'blue'); foreach($arr ...

  7. iOS一些常用的小知识点

    //获取全局的Delegate对象,这样我们可以调用这个对象里的方法和变量 [[UIApplication sharedApplication] delegate]; //获得程序的主Bundle N ...

  8. 关于android的UI更新机制与误区

    Android系统的消息队列和消息循环都是主线程的,其它后台服务等无法直接更新,必须通过下面的消息队列,由主线程的消息循环去依次执行更新ui: 同时对于费时间超过5秒的事件,比如网络链接等,建议新开线 ...

  9. NSIS 让程序以管理权限运行

    用NSIS向导,制作安装包,会生成NSI扩展的脚本文件,按F9,即可以生成安装文件. 如果要以管理员权限运行,直接在nsi脚本中,添加RequestExecutionLevel admin Name ...

  10. X删除数据表的新用法

    删除数据表,可以这样进行,以前傻不拉唧的用sql去手动删除.             DAL dal = ...             dal.Db.CreateMetaData().SetSche ...