I have a WPF DataGrid bound to a ObservableCollection via dg.ItemsSource = myCollection;
The MyClass implements INotifyPropertyChanged. I have a calculated property which is calculated async.
The property is a SolidColorBrush bound to the color of the Text. After the value of the property changes the DataGrid does not update immediately, but it updates as soons as I select the line of the item of which the property changed it display the updated value.
What can I do to let the DataGrid update immediately? I can't use XAML binding for the ItemsSource.
Binding:
<DataGridTextColumn Foreground={Binding Path=MyBrushProperty} />
Code of the class:
public class MyClass : INotifyPropertyChanged
{
public SolidColorBrush MyBrushProperty {
get {
CalcMyBrush();
return _myBrushProperty;
}
set{
_myBrushProperty = value;
OnPropertyChanged("MyBrushProperty");
}
}
private void CalcMyBrush(){
//DoSomething that changes _myBrushProperty and takes some time and needs to run async and after that sets
MyBrushProperty = somevalue;
}
}
Foreground={Binding Path=MyColorProperty,IsAsync=True}. - Rohit VatsI can't use XAML binding in this case- What? - Federico Berasategui