2

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?

kereberos
  • 1,253
  • 1
  • 10
  • 20
  • This [question](http://stackoverflow.com/questions/552756/can-silverlight-initiate-page-refreshes) may help. – CodeNaked Jun 16 '11 at 18:59
  • What exactly an "action" does over the grids? – NestorArturo Jun 16 '11 at 19:26
  • 2
    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. – iCollect.it Ltd Jun 16 '11 at 20:43

1 Answers1

0

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.

Josh C.
  • 4,303
  • 5
  • 30
  • 51