How to force notifying DataContext changed? #15229
Unanswered
liwuqingxin
asked this question in
Q&A
Replies: 1 comment 8 replies
-
that's a task for your ItemViewModel. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone!
EDIT 1 --------
More broadly, the question is how to force to notify an AvaloniaProperty changed, even it is not changed actually.
For an instance that implemented INotifyPropertyChanged, we can use instance.PropertyChanged(...) to do that. But with AvaloniaObject's AvaloniaProperty, how to do that?
END EDIT 1 --------
I have a custom DataGrid control. I use static expression like 'value / sum(value)' to calculate some column's value. In that situation, the calculation only performs when the DataContext of the row, which is also the cells'DataContext, is changed or the control is creating.
Now when I update a rowdata.value from '10' to '20', I want to force to notify that the DataRow's DataContext is changed, to update the expression column's cell. How can I do that efficiently?
I try to set the DataContext of the DataRow to null first and then set it back immediately. It works, but is not efficient enough. The DataContext updated twice in that way.
So, I would like to find out an api that is like INotifyPropertyChanged.PropertyChanged, which can notify the AvaloniaProperty change even if it is not changed actually.
Many thanks!
Beta Was this translation helpful? Give feedback.
All reactions