积极答复者
How to delete all the Lines in my inkcanvas control

问题
-
I have draw some Lines in one of the InkCanvas. code like below:
double y = value; while (y < heightCanvas) { Line line = new Line(); line.X1 = 0; line.Y1 = y; line.X2 = widthCanvas; line.Y2 = y; line.Stroke = Brushes.LightBlue; this.inkCanv.Children.Add(line); y += value; }
But now I want a Slider to control the lines on inkcanvas to make it with grids.
When draw new Lines, how could I remove all the old lines on it? But not remove other shapes and strokes on it .
Any good suggestiona? Thank you!
答案
-
你好,
你现在发帖的这个论坛是中文支持的MSDN论坛,你可以尝试用中文进行提问,这样会方便有更多的论坛成员阅读你的帖子,清楚的明白你的问题,同时 你也可以获得更多更好的解决方案。
If you want to ask your question and get your answer as the English, I think you could try to post your issue at this forum, the link is:
http://social.msdn.microsoft.com/Forums/en-US/wpf/
这里是中文论坛,因此,我将用中文对你的问题进行回答。
首先,我回答你最关心的问题,然后对你的相关问题和你进行讨论,希望我们可以共同解决你的问题。
--> Any good suggestiona?
因为在InkCanvas上面创建的笔画都是Stroke对象,因此你可以自己建立一个Stroke对象的Collection,去存储那些Shapes或者Lines,然后你可以利用一些InkCanvas的事件去完成Stroke对象的删除(Remove)。我想这样可以完成你的需求。
下面是一些关于这个主题的链接,你可以参考一下:
http://www.codeproject.com/KB/WPF/InkCanvas.aspx?display=Print
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/338da0b0-23d6-491f-b11d-b4cc0f2aa453
问题讨论:
根据你所提供的代码,我想你已经阅读过Codeproject 上的这篇文章(http://www.codeproject.com/KB/WPF/Ink1.aspx),并且基本上已经完成了你的目标(项目)。
但是,对于你关于问题的描述我还是有一些不太清楚的地方,我希望你能为我提供更详细的说明,这样我可以为你提供更好的建议或者解决方案。
1)--> make it with grids
可以详细的描述一下这里的意思么?
2)--> But now I want a Slider to control the lines on inkcanvas to make it with grids.
在你的项目中你是用Slider去控制InkCanvas上面那些线的什么属性么? 改变大小,类似下面代码那样?
<InkCanvas.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=zoomSlider,Path=Value}" ScaleY="{Binding ElementName=zoomSlider,Path=Value}"/>
</InkCanvas.LayoutTransform>
但是为什么因为这个要删除以前画的线而且不删除其他的图形呢? 能够告诉你最终是要实现一个什么样的结果么?如果我了解了这些,有可能会增加去得到同样效果途径。
Best regards,
Sheldon _Xiao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 Jarrey 2011年2月15日 15:43
- 已标记为答案 Sheldon _XiaoModerator 2011年2月21日 5:54
全部回复
-
你好,
你现在发帖的这个论坛是中文支持的MSDN论坛,你可以尝试用中文进行提问,这样会方便有更多的论坛成员阅读你的帖子,清楚的明白你的问题,同时 你也可以获得更多更好的解决方案。
If you want to ask your question and get your answer as the English, I think you could try to post your issue at this forum, the link is:
http://social.msdn.microsoft.com/Forums/en-US/wpf/
这里是中文论坛,因此,我将用中文对你的问题进行回答。
首先,我回答你最关心的问题,然后对你的相关问题和你进行讨论,希望我们可以共同解决你的问题。
--> Any good suggestiona?
因为在InkCanvas上面创建的笔画都是Stroke对象,因此你可以自己建立一个Stroke对象的Collection,去存储那些Shapes或者Lines,然后你可以利用一些InkCanvas的事件去完成Stroke对象的删除(Remove)。我想这样可以完成你的需求。
下面是一些关于这个主题的链接,你可以参考一下:
http://www.codeproject.com/KB/WPF/InkCanvas.aspx?display=Print
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/338da0b0-23d6-491f-b11d-b4cc0f2aa453
问题讨论:
根据你所提供的代码,我想你已经阅读过Codeproject 上的这篇文章(http://www.codeproject.com/KB/WPF/Ink1.aspx),并且基本上已经完成了你的目标(项目)。
但是,对于你关于问题的描述我还是有一些不太清楚的地方,我希望你能为我提供更详细的说明,这样我可以为你提供更好的建议或者解决方案。
1)--> make it with grids
可以详细的描述一下这里的意思么?
2)--> But now I want a Slider to control the lines on inkcanvas to make it with grids.
在你的项目中你是用Slider去控制InkCanvas上面那些线的什么属性么? 改变大小,类似下面代码那样?
<InkCanvas.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=zoomSlider,Path=Value}" ScaleY="{Binding ElementName=zoomSlider,Path=Value}"/>
</InkCanvas.LayoutTransform>
但是为什么因为这个要删除以前画的线而且不删除其他的图形呢? 能够告诉你最终是要实现一个什么样的结果么?如果我了解了这些,有可能会增加去得到同样效果途径。
Best regards,
Sheldon _Xiao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 Jarrey 2011年2月15日 15:43
- 已标记为答案 Sheldon _XiaoModerator 2011年2月21日 5:54
-
你好 hahasong,
由于你没有继续的给我们提供关于你问题状态的信息,因此我们认为你的问题已经得以解决。
我将标记包含有用信息的回复作为答案,这样方便跟你有同样疑惑的成员找到问题的答案。
Best regards,
Sheldon _Xiao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.