Click here to Skip to main content
Rate this: bad
good
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
good
Please Sign up or sign in to vote.

Solution 1

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!
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 310
1 PhilLenoir 164
2 Richard MacCutchan 160
3 Sharmanuj 146
4 Magic Wonder 129
0 Sergey Alexandrovich Kryukov 6,081
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2014
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