Geeks With Blogs
Adrian Hara Working through the .NET maze

If you have a Silverlight 3 Beta 1 DataGrid that, for some reason, is not refreshing when its bound ItemsSource changes, like so...

 <data:DataGrid ItemsSource="{Binding Path=Parameters}" AutoGenerateColumns="false" IsReadOnly="True" >
                     
...you might want to know that it's a bug in the beta. I actually spent about 2 days on and off on this issue, researching a workaround and googling for it with no results. Only today, more on a guess than anything else, I did this:

 <data:DataGrid ItemsSource="{Binding Path=Parameters, Mode=TwoWay}" AutoGenerateColumns="false" IsReadOnly="True" >

It's obviously stupid to have a readonly grid with TwoWay binding but, to my surprise, it started working ;)

Armed with this knowledge, I refined my google searches and voila, the following thread magically appeared. The link to the repro in the thread isn't working, but I assume it's about the problem at hand. So, anyway, just use TwoWay binding in the meantime ;)

update: I also noticed the same behavior for binding paths that go "deeper" in the bound object (e.g. "SelectedParameter.Value"), even if they are NOT used for the DataGrid (i.e. I have a case that's not working for a Button). Luckily, the same workaround works there too. The downside is that you have to be careful to not really use the TwoWay binding, thus inadvertently updating your ViewModel.

 

Posted on Friday, April 17, 2009 2:54 PM | Back to top


Comments on this post: Silverlight 3 Beta 1 DataGrid not refreshing bug

# re: Silverlight 3 Beta 1 DataGrid not refreshing bug
Requesting Gravatar...
This is a stupid answer .. by changing Mode=TwoWay .... i follow the same step but i have refresh issue ... anybody know how to do this?
Left by surath on Feb 15, 2011 10:44 PM

Your comment:
 (will show your gravatar)


Copyright © Adrian Hara | Powered by: GeeksWithBlogs.net