Linked Silverlight TextBox loses data when browser closes

When I bind a TextBox control to a string property of an object using two-way binding, it works fine - until the user disables the control before it closes the browser window / tab.

But what about a user who makes changes to the contents of a text field, then closes a window waiting to save data?

As long as you can hook up the TextChanged or Application_Exit () handler and manually update the property, you essentially re-do the work of the binder. However, these are the only solutions so far.

pi The same xaml / code in the WPF application works fine (App.OnExit shows updated data in the object).

+3
source share
3 answers

I make an educated guess based on significant web development experience but very limited Silverlight experience.

You can use a bit of Javascript to connect to onunload in HTML, and then call a function in your Silverlight code to process it.

+1
source

This seems to be a problem with Silverlight. It does not update the associated property in the text box until it loses focus.

The workaround I had to use (I used a dynamic filter) was to implement the TextChanged event handler and update the backup property manually.

+1
source

Silverlight Binding UpdateSourceTrigger? WPF , ( ), :

<TextBox Text="{Binding Path=Foo,UpdateSourceTrigger=PropertyChanged}" />
0
source

Source: https://habr.com/ru/post/1703643/


All Articles