by StefanOlson via Stefan Olson's Blog on 10/30/2008 12:44:00 PM
As I mentioned in my post Silverlight 2 RTW Bugs data binding is basically broken in Silverlight 2. I wasn't at the time entirely sure exactly what the reason was, but I have now discovered it (or part of it). It turns out that custom Dependency Properties, on which I rely for my data binding do not actually notify bindings of a change in state. This is of course completely inconsistent with WPF and makes maintaining code between Silverlight in WPF even more difficult. Hopefully the issue will be fixed in the next release of Silverlight. My understanding is that the reason that was done this way was to keep the DependencyProperty system as small and fast as possible. Unfortunately makes the programmer's life substantially more difficult!
So, how do we solve this problem? This post Silverlight 2.0 - Bug with Data Binding? has a detailed description, including code, showing how to use INotifyPropertyChanged in your DependencyProperty changed handler. As you can imagine with a large code base like we have for the Virtual Tour Viewer this is quite a massive amount of work and the original point of using Dependency Properties is that the change handling was automatic!
However, this solution proposed above will only work for situations where you can get a change notification. There are a number of scenarios in Silverlight where there are simply no notifications. So in many cases we are largely back at square one. Mostly what I've had to do in the Virtual Tour Viewer is try and handle events and update my user interface that way. This has of course resulted in an explosion of code for the Silverlight version of the tour and I have #if SILVERLIGHT all over the place. Really you just have to be pragmatic about things otherwise you'd never actually get the job done.
So the best thing we can do at this point is to lobby Microsoft to make changes in the next version of Silverlight that will resolve these issues and bring consistency with WPF.
...Stefan
Original Post: Silverlight Data Binding bugs explained
The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.