Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
help me, Im stuck with my code.
I have some doubt Plz Verify me..
1. How i can refresh my usercontrol? is it UpdateLayout() enough?

its(UC)now added to mainwindow as child of a grid itself. but need to refresh this UC with new value, but data is supplied from a separate window. that window contain a listview, on this selection change need to refresh this usercontrol..

please help me its very urgent..

thanks in advance .
Posted

1 solution

Hello
To get automatic updates from properties in the model (code) to the view (gui), there are some things you should ensure.

1) You should use Bindings from the view to the model
2) The properties in the model that are used in Bindings should also have a DependencyProperty in the class
3) The model class itself should implement the INotifyPropertyChanged interface so the properties can notify changes.
4) Lists should be ObservableCollection<> instead of List<> because it inherits the ICollectionChanged interface.

This way, you will never again worry about UpdateLayout() or DoEvents() or anything like that.

If you like to update the values "live" while running a long-running method in the model, you should run that method in a Thread, like i.e. a BackgroundWorker.

Hope it helps!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900