Click here to Skip to main content
13,049,814 members (63,654 online)
Rate this:
Please Sign up or sign in to vote.
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 3-Dec-12 23:44pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100