wpf - How to implement DataTable property with INotifyPropertyChanged -


I have created a WPF MVVM application, and WPToolkit has created DataGrid for DataTable so that I can know that the DataTable property To inform how to be implemented, changed. Currently my code is like below.

  Public Data Test Test {get {this.testTable; } Set {... ... base.OnPropertyChanged ("Test"); }} Public Zero X () {this.Test.Add (...); // I think this line will call the recipient first (get it Test = test) and then it is called Joint Letter, this means that the setter will never be scope. Base.OnPropertyChanged ("Test"); // My solution is here :) but I hope there are better ways to do this}  

Is there another solution to this problem?

You can change 2 ways in your table data: either an element can be added / removed from the archive Or some properties can change from within an element.

The first scenario is easy to handle: Make your collection to include a . (T item) or . View deleted items (by you) on your table (and the table will update accordingly) / P>

The second scenario is where you have INOTifyPropertyChanged Your tee object is needed to implement ...

Finally your code should look something like this:

  Public class MyViewModel {public supervision collection & lt; MyObject & gt; MyData {Received; Set; }} Public class MyObject: INotifyPropertyChanged {Public MyObject () {} Private String _States; Public string status {get {return_status; } Set {if (_status! = Value) {_status = value; RaisePropertyChanged ("Status"); // Change the name of the property here pass here}}} Public Event Property ChangedEventHandler property changed; Private Zero RaisePropertyChanged (string propertyName) {PropertyChangedEventHandler Handler = this.PropertyChanged; If (handler! = Null) {var e = new asset changed apprentase (property name); Handler (it, E); }}}  

Now to set an example of your view model, set up the doccontactor of your scene, and tie it in the archive, such as:

  & Lt; Tk: DataGrade ItemsSource = "{Binding Path = Moody}" ... />  

Hope this helps :) Ian


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -