积极答复者
调用 Grid.Children.Add(XXX) 时,报错“参数不正确”/“The parameter is incorrect.”

问题
-
我在编写一个wp7小游戏的时,将若干个(42个)用户控件添加到Grid时报错:
“参数不正确”
“The parameter is incorrect.”
以下是代码:
grid_PipeContainer.Children.Clear(); for (int y = 0; y < this._plumberGame.VerticalPipesCount; y++) { for (int x = 0; x < this._plumberGame.HorizontalPipesCount; x++) { var pipe = this._plumberGame.PipesData[y, x]; var pipeControl = new PipeControl(); pipeControl.PipeType = pipe.Type; pipeControl.PipeDirection = pipe.Direction; pipeControl.IsThrough = pipe.IsThrough; pipeControl.Tag = pipe; Grid.SetRow(pipeControl, y); Grid.SetColumn(pipeControl, x); pipeControl.Click += new EventHandler(pipeControl_Click); grid_PipeContainer.Children.Add(pipeControl);//此处报错 } }
此错误并不是每次都报,如果用wp7模拟器的话,10次里有7次都报错,部署到真机上,10次有3次都报错,
目前我还没有找到是什么原因导致的错误,
请高手们帮帮忙,如果需要,我可以提供源码给你们测试,
- 已编辑 jesse hao 2012年3月10日 11:04 错别字
答案
-
你好,
我模拟了一下你的代码,但不能重现你的问题。
另外这里是Silverlight论坛,你的问题是关于WP7 的,所以我建议你到WP7相关论坛提问会更好一些:
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series
http://social.microsoft.com/Forums/zh-CN/windowsmobilezhchs/threads
Daoping Liu - MSFT
- 已标记为答案 jesse hao 2012年3月13日 10:45
-
多谢回答,我也wp7板块也发过,问题已解决:
多谢多谢,
- 已标记为答案 Daoping Liu - MSFTModerator 2012年3月14日 2:27
全部回复
-
你好,
我模拟了一下你的代码,但不能重现你的问题。
另外这里是Silverlight论坛,你的问题是关于WP7 的,所以我建议你到WP7相关论坛提问会更好一些:
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series
http://social.microsoft.com/Forums/zh-CN/windowsmobilezhchs/threads
Daoping Liu - MSFT
- 已标记为答案 jesse hao 2012年3月13日 10:45
-
多谢回答,我也wp7板块也发过,问题已解决:
多谢多谢,
- 已标记为答案 Daoping Liu - MSFTModerator 2012年3月14日 2:27