views:

70

answers:

2

Hi!

How can i add a control to a Silverlight Grid control without blocking the user interface. I am creating a complicated Chart control and when i call myGrid.Children.Add(myChart) the whole page is blocked and not responding. Any idea guys?

A: 

Have you tested whether this is a XAML rendering issue or instantiating the chart control that is causing the blocking?

What happens when you set the Visibility of the chart to Collapsed and add that to the grid? Obviously you won't see it on the UI, so you'll either need to step through it via debug or simply pop up a MessageBox before and after you call the Add(myChart).

If it is the XAML rendering of the chart, I'd dive deeper into the XAML that chart control and look for optimizations (if you can, what chart control is this?).

Andy May
Actually a tried to set visibility collapsed and is all ok until i set the chart control to visible again. I guess is the chart rendering then that takes up a lot of time. Time is not the issue though, it is the UI blocking until the chart appears...
Elz
If this is a render issue you might be stuck. The UI is its own thread. What chart control is this? Telerik? Silverlight Toolkit?
Andy May
+2  A: 

A few things you could try:

  1. Wrap your call to add the chart inside of Dispatcher.BeginInvoke([add chart]). This will cause the chart to not be added until the current round of UI work is done and may help it be more responsive.
  2. Add the chart without any data to the UI. Then in the background load the data and use bindings to have the data rendered in the chart.
  3. Try to figure out how you can break apart your complicated chart. So maybe you can add the chart first, then add some of the other items as you go.
  4. Make sure your data for the chart is already loaded before you add the chart. I'm assuming you're already doing this, but just want to double check.

Those are my only ideas.

Bryant