Reputation: 161
I am creating Windows Application which has a Grid. Grid's data source is a an Object of a Class. Grid has two bands. As shown in the below image on Band1, there is a Column named as Templates. It has values from 1 to 10. The requirement is that based on the selected values in the Template Field, Band2 must have no of rows. e.g. if User selects 2 in the Template Field, Band2 must have two rows. As its a run time process, Grid must be refreshed on the Run time.
In the below case if the value is changed from 2 to 3 in the template field, the open Band2 must be refreshed to show 3 rows. I wrote some code but it was not able to refresh the grid on the run time.
private void grdDataMapping_AfterCellUpdate(object sender, CellEventArgs e)
{
if (e.Cell.Column.Key.Equals("TemplateName"))
{
ValueList paramName = new ValueList();
string templateName = e.Cell.Text;
List<TemplateMapping> tempMappings = new List<TemplateMapping>();
if (_dictTemplateNames.ContainsKey(templateName))
{
for (int i = 0; i < templateName.Value; i++)
tempMappings.Add(new TemplateMapping());
mappingDetails.ListTemplateMapping = tempMappings;
}
grdDataMapping.Refresh();
}
What am I missing here?
Upvotes: 0
Views: 351
Reputation: 972
You could implement the interface INotifyPropertyChanged
and some additional properties you may notify of. This way the ViewModel notifies the View (or vice versa) about any changes that have been made. Thus, you can easily control the content of all 3 DataGrids.
See INotifyPropertyChanged for more on this. There are plenty of articles around who help you archiving this.
Upvotes: 1