Quantcast
Channel: WPF datagrid new row event
Viewing all articles
Browse latest Browse all 6

WPF datagrid new row event

$
0
0

For my benefit, let's call the type you hold your data in the model.

Let's call the type the datagrid binds to the viewmodel.

( I'd have another viewmodel for the window which contained an observable collection of these viewmodels.

My viewmodel would have two public properties ( at least ).

One would be isnew, the other would be model.

I'd have a default value for isnew = true.

When I load up my data out the database I'd set the value of isnew to false.

And the model in the viewmodel would be a reference rather than a copy of the model out the database.

Roughly like this aircode:

public class myrowviewmodel()
{
 public myrowViewodel( bool isNew = false)
 {
   IsNew = isNew;
 }
  public bool IsNew {get; set;}
  public model{get; set;}
}

Or a default parameter on the constructor or whatever.

And some foreach adds data out your source into the collection, but with a parameter.

 


Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>