重绘 Silverlight 画布
在我的应用程序中,我根据我拥有的一些数据绘制一个房间。在那个“房间”里,我有架子(只不过是布局网格)。用户可以对代表货架部分的网格中的单元格执行多项操作。 (比如将货架空间专门用于产品)。一旦对房间的操作完成,我想重新绘制房间,就像页面刚刚第一次加载一样。我似乎无法让它发挥作用。
我尝试清除画布子项,然后导航回房间,但我只得到一个空白页。代码非常简单:
LayoutRoot.Children.Clear();
NavigationService.Navigate(new Uri("/TheRoom", UriKind.Relative));
我尝试了许多其他方法,但没有一个有效。谁能告诉我我在这里使用的方法是否正确,或者我是否遗漏了一些你可以看到的东西?
In my application I am drawing a room based on some data I have. In that "room" I have shelves (which are nothing more than layout grids). The user can perform several actions against the cells in those grids representing the sections of a shelf. (like dedicating shelf space to a product). Once an action is completed against the room, I would like to redraw the room as though the page had just loaded for the first time. I cannot seem to get that to work.
I have tried to clear the canvas children and then navigate back to the room, but I only get a blank page. The code is pretty simple:
LayoutRoot.Children.Clear();
NavigationService.Navigate(new Uri("/TheRoom", UriKind.Relative));
I have tried numerous other methods but none of them have worked. Can anyone please tell me if I am using the right approach here or is there something I am missing that you can see?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用 InvalidateArrange() 怎么样?或 InvalidateVisual();我不记得其中哪些功能可用于 Canvas 与 Panel 以及 Silverlight 与 WPF,但我知道其中一些是可用的。
如果 Canvas 没有提供适当的失效方法,您始终可以继承 panel 并创建自己的“Canvas”并重写 InvalidateArrange() 来执行您需要的操作。
What about calling InvalidateArrange(); or InvalidateVisual(); I can't recall which of those functions are available for Canvas vs Panel and Silverlight vs WPF, but I know some of them are.
If Canvas doesn't offer what the appropriate invalidation method, you can always inherit panel and create your own "Canvas" and override InvalidateArrange() to do what you need.