【发布时间】:2011-09-23 08:41:35
【问题描述】:
有人可以帮我解决这个问题:如何将图形划分为字段,以便根据鼠标单击的区域来执行特定事件?
private void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//if (!isDragging)
{
//creating of my user control element
NodePicture node = new NodePicture();
node.Width = 100;
node.Height = 100;
//use cursor position as the center of the figure
Point point = e.GetPosition(this);
node.SetValue(Canvas.TopProperty, point.Y - node.Height / 2);
node.SetValue(Canvas.LeftProperty, point.X - node.Width / 2);
node.MouseLeftButtonDown += controlReletionshipsLine;
LayoutRoot.Children.Add(node);
}
}
private void controlReletionshipsLine(object sender, MouseButtonEventArgs e)
{
//creating parant element of node
ParentNode parentNode = new ParentNode();
//creating connected element of the node
ConnectedNode connectedNode = new ConnectedNode();
//creating node element
NodePicture node = (NodePicture)sender;
//getting the relative position of the element
Point point = e.GetPosition(this);
【问题讨论】:
-
需要更多详细信息。你说的图是什么意思??
-
比如一个圆圈,我需要把它分成几个部分。@Myles J
-
是不是和html地图有点像?
-
可能是这样的,但是当你点击它时,它应该被称为一个事件。@baalazamon
-
圈子?好的,我们谈论的是椭圆形对象或图像吗?
标签: c# asp.net silverlight silverlight-4.0 silverlight-3.0