Updating TextBox in Silverlight 5

Updating TextBox in Silverlight 5

Old forum URL: forums.lhotka.net/forums/t/10990.aspx

Killian35 posted on Thursday, December 15, 2011


I've just upgraded a Csla application to Silverlight 5 and have found a strange behavior. I have properties that get formatted using business rules after they have been entered in a TextBox do not get reflected back in the TextBox. What I'm noticing now is that the TextBox does no longer reflects the updated value. To test this further I created a simple Silverlight app with a class that implemented a single property using the INotifyPropertyChanged interface to cut Csla out of the picture completely. I would format the value in the set method and call OnPropertyChanged, but still the TextBox did not reflect the newly formatted value. If I changed the property externally through a button even, then TextBox would update accordingly. Just not if the textbox itself is changing the property. I'm very sure this was working in Silverlight 4. I'm not sure if things have changed in Silverlight 5 and I missed it or if something is wrong. Can anyone confirm this behavior?

RockfordLhotka replied on Friday, December 16, 2011

it is possible that SL5 is closer to WPF in this regard, where changed properties aren't echoed into the UI unless the binding has a value convter attached. That would be a shame, because I always viewed this as a bug. But Microsoft views it as a performance optimization...

try attaching a value converter and see if that helps.

Killian35 replied on Friday, December 16, 2011

Thanks for your response, Rocky. Since the issue is not Csla based, I won't further the discussion here. However, I would like to point out that the non-updating occurs only while running in the IDE. I use IE in the IDE for debugging, as well. Outside of the IDE, the TextBox gets updated with the newly formatted value just fine. So it appears that the SL team may have (inadvertently?) changed something while debugging in SL. 

RockfordLhotka replied on Friday, December 16, 2011

So this only occurs during debugging? That could just be a bug in SL5 then.

Copyright (c) Marimer LLC