Hi,
You should not want to traverse the datagrid. What you need to do is create a structure containing your data, inclusive of the textcolor you need like:
class GridData : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private int _number;
private SolidColorBrush _textColor;
public int Number
{
get { return _number; }
set
{
number = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Number"));
}
}
public SolidColorBrush TextColor
{
get { return _textColor; }
set
{
_textColor = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("TextColor"));
}
}
}
Now, in your XAML, bind the Number property to the "Text" property of the textbox used in your grid columntemplate, and bind the TextColor property to the "Foreground" property of the same textbox.
Whenever you change the TextColor property from your dataclass to another color, the PropertyChanged event will inform the grid of the change and display the desired color. so, no need to traverse the grid itself, just manipulate the underlying data.
Hope this helps in any way...
Regards, Perry