//图像加载
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. AngularJs的UI组件ui-Bootstrap分享(十二)——Rating

    Rating是一个用于打分或排名的控件.看一个最简单的例子: <!DOCTYPE html> <html ng-app="ui.bootstrap.demo" x ...

  2. red hat enterprise 6安装tftp服务

    1--->检查是否安装tftp rpm -qa tftp* 2--->安装tftp yum install -y tftp-server 3--->chkconfig --list| ...

  3. 对象序列化到本地文件 ObjectOutputstream ObjcetInputstream

    package com.main.test; import java.io.FileInputStream; import java.io.FileNotFoundException; import ...

  4. jquery 触发/失去焦点事件例子详解

    触发焦点: $("Element").focus() 触发每一个匹配元素获得焦点事件. $("Element").focus(function) 事件会在获得焦 ...

  5. K均值聚类算法的MATLAB实现

    1.K-均值聚类法的概述    之前在参加数学建模的过程中用到过这种聚类方法,但是当时只是简单知道了在matlab中如何调用工具箱进行聚类,并不是特别清楚它的原理.最近因为在学模式识别,又重新接触了这 ...

  6. entity framework 新手入门篇(2)-entity framework基本的增删改查

    经过前两节的简单描述,终于可以进入entity framework的使用部分了.本节将对entity framework原生的增删改查进行讲解. 承接上面的部分,我们有一个叫做House的数据库,其中 ...

  7. C++11 auto_ptr 的问题

    auto_ptr作为最早的智能指针,可以实现以RAII手法管理堆区对象,但它设计的本意只是简单的利用C++对于栈区对象的自动析构管理堆区对象, 并不像shared_ptr那样包含引用计数,可以在每次拷 ...

  8. adb -s emulator-5554 install JDKCast-PAP.apk

    multi-emulators direct to install app adb -s emulator-5554 install JDKCast-PAP.apk

  9. Maven项目下java.lang.ClassNotFoundException的解决方法

    问题背景: Maven的project下,项目中已经引用了相应的jar包.Java class中没有语法错误,在执行时报ClassNotFound.检查了Maven的pom.xml,依赖引入正常. 错 ...

  10. time元素和datetime、pubtime属性

    time:对一个时间进行标识 <time datetime="2012-12-24">2012-12-24</time> datetime:时间的值 pub ...