2
votes

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?

1
This question may help. - CodeNaked
What exactly an "action" does over the grids? - NestorArturo
If you navigate to the current page it will not reload. Why don't you just call your code to populate the room again immediately after clearing the visual tree? We really need more information about how your page works to provide any real solutions. - Gone Coding

1 Answers

0
votes

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.