Silverlight RadChart :创建十字定位&圈选
//图像加载
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 :创建十字定位&圈选的更多相关文章
- HTML <select> 标签 创建单选或多选菜单
所有主流浏览器都支持 <select> 标签. select 元素可创建单选或多选菜单. <select&> 元素中的 <option> 标签用于定义列表中 ...
- Silverlight 之 创建
Silverlight 项目文件是您可以使用不同工具来创建和编辑的文本文件.例如,可以使用 Visual Studio 2010 以及 Expression Blend 来创建 Silve ...
- QT 创建一个具有复选功能的下拉列表控件
最近研究了好多东西,前两天突然想做一个具有复选功能的下拉列表框.然后在网上"学习"了很久之后,终于发现了一个可以用的,特地发出来记录一下. 一.第一步肯定是先创建一个PROJECT ...
- C++第四十三篇 -- VS2017创建控制台程序勾选MFC类库
用VS2017创建EXE带MFC类库方法 1. File --> New --> Project 2. Windows桌面向导 3. 勾选MFC类库 4. 创建成功 如果项目编译出错 1. ...
- Silverlight 动态创建Enum
private Type CreateEnum() { List<string> lists = new List<string>(); lists.Add("男&q ...
- 使用Visual Studio 2010 创建简单的Silverlight应用程序
使用Visual Studio 2010 创建简单的Silverlight应用程序 Silverlight是创建动态的引人的RIAs(Rich Internet Application)的新方法.这里 ...
- iOS iOS9.0 的CoreLocation定位
一.简介 iOS9.0如果当前处于前台授权状态,默认是不可以后台获取用户位置. 如果在前台授权下,让其能获取到后台定位,该怎么办 可以设置以下属性为YES,就可以继续获取后台位置,但是会出现蓝条 使用 ...
- ArcGIS API for Silverlight开发入门
你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我 都没关系.但你不能否认3G是一种趋势,最终我们每个人都会被包裹在3G网络中.1100也不是一成不变,没准哪天为了打击 ...
- QT中静态库的生成与使用——创建共享库代码,附例子
一. 静态库的生成 1. 测试目录: lib 2. 源码文件名: mywindow.h, mywindow.cpp, 类MyWindow继承于QPushButton, 并将文字设置为&qu ...
随机推荐
- Two Sum (c#)
Given an array of integers, find two numbers such that they add up to a specific target number. The ...
- swift 定位
iOS 8 及以上需要在info.plist文件中添加下面两个属性 NSLocationWhenInUseUsageDescription 使用应用期间 NSLocationAlwaysUsageDe ...
- 006-Map、Tuple、Zip实战解析
006-Map.Tuple.Zip实战解析 实战代码 Map实战 本身是映射,映射关系在实际中应用非常广泛,比如:配置信息都是Key-Value形式 键值对不存在下边关系 是一个immutable(不 ...
- LoadRunner录制一个登录
1.点击录制脚本 2.点击左边页面加号
- 移除project,testsuite,testcase级别所有的custom properties
// Remove all custom properties on Project level. If removed, custom properties cannnot be injected ...
- JavaScript document属性和方法
JavaScript document属性和方法 --------------------------------------------属性: 1. Attributes 存储节点的属性列表 ...
- WebService 生成类的命令语句
在开发项目中,有时候需要调用webservice接口程序,根据项目规定有的项目是直接引入接口,有的是需要把接口生成代理类的形式在项目中使用,根据项目需要来取舍. 以下列出项目中常用的Webservic ...
- 滑动的scrollowview的导航渐变
CGFloat offsetY = scrollView.contentOffset.y; CGFloat alpha = 0; if (offsetY >= 64) { alpha=((off ...
- Android 数据库管理— — —添加数据
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=" ...
- .net core 学习笔记(2)-中间件
小项目中有个操作日志的功能,主要是记录用户对修改数据的操作进行记录,记录的内容包括 访问的控制器和方法,以及控制器方法中接收的参数,操作用户,及操作IP等信息,最开始是用ActionFilterAtt ...