I do the same.
The only problem with properties is that the automatic data binding with the key of DataGrid columns expects dictionary or dictionary-like objects, so I always derive my classes from the AttributeToKey
class described here.
Data binding on most components can be any of these (considering self.item
is a box of cookies):
# full expression in data binding
sum(1 for c in self.item.cookies if cookie.color == 'red']
# pre-calculated value in dictionary
self.item["n_red_cookies"]
# property that calculates the value
self.item.n_red_cookies
Driving a class from AttributeToKey
allows to use n_red_cookies
as the key on DataGrid columns.