This is a migrated thread and some comments may be shown as answers.

Should setting DataContext update the UI automatically?

2 Answers 124 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 27 May 2011, 12:56 PM

We have a Silverlight object embedded in an aspx-page. When the page loads, the Silverlight component loads like it should and gets some data from a web service, which is bound nicely to ScheduleView's DataContext.

When a user clicks a button on the aspx-page the server generates new data and uses ScriptManager.RegisterStartupScript to call a JavaScript function which in turn calls a method in the Silverlight component to refresh the data from the web service. The web service returns the new data which is converted to a ViewModel and bound to ScheduleView's DataContext. Setting the DataContext doesn't update ScheduleView with the new data though. What should be done so that the ScheduleView would update?

I've been following the article "RadScheduleView for Silverlight - Implementing View-ViewModel". In addition there's just the JavaScript on the aspx-page which calls a method in the code-behind for MainPage and gets the new data from the web service. The DataContext is then set during the AsyncCompleted event.

Edit: Does this have to do with the UI not refreshing because the DataContext is set in the AsyncCompleted event? RadScheduleView implements IPropertyChangedListener, is it related? Where can I find information about the interface?

Edit2: Setting the CurrentDate property in the same method updates the DateGroupDescription, but setting DataContext doesn't update the ResourceGroupDescriptions or the Appointments.

Thank you.

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 31 May 2011, 10:34 AM
Hello Seppo,

I've tried to reproduce the described issue in a simple application but without much success. I've attached the application, can you please download it and give it a try? Can you modify in order to reproduce the problem?

Regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Markus
Top achievements
Rank 1
answered on 01 Jun 2011, 06:50 AM

Hello and thank you for your sample.

I modified it a bit according to our project and it worked. After a few more hours of annyoing debugging, I somehow managed to get the DataContext to refresh.

I think there was some kind of problem with the Resources that were added to the DataContext.

Tags
ScheduleView
Asked by
Markus
Top achievements
Rank 1
Answers by
Yana
Telerik team
Markus
Top achievements
Rank 1
Share this question
or