Do not create the datagrid manually but use
ObservableCollection
.
This way you can easily manipulate values in code behind, changes work both ways.
Here is an example for a ListView:
private ObservableCollection<MyListViewItem> myListViewItems = new ObservableCollection<MyListViewItem>();
ListView1.ItemsSource = this.myListViewItems;
public class MyListViewItem
{
public MyListViewItem()
{
}
public MyListViewItem(string name, string value, string group, string tag, SolidColorBrush color)
{
this.Name = name;
this.Value = value;
this.Group = group;
this.Tag = tag;
this.StatusColor = color;
}
public string Name { get; set; }
public string Value { get; set; }
public string Group { get; set; }
public string Tag { get; set; }
public SolidColorBrush StatusColor { get; set; }
}