I'm binding a DataGrid
to an ObservableCollection<MyModel>
. The grid consists of some columns that are bound to properties of the model via <DataGridTextColumn Content="{Binding LastName}" />
etc., which works fine.
Now I want to add a column SumOfAllReferencesToMyModelInstance
to the grid with a calculated value, which takes the Id
property of each MyModel
in the collection and uses it to count the instance's occurrences in some other places, resulting in different values for each instance / grid row. I can easily bind the column to a custom property in my view model, but I fail to get a reference to the currently evaluated MyModel
instance to read its Id
, which apparently I need for the calculation. How can I achieve this?
I'd like to avoid adding a SumOfAllReferencesToMe
property to the model class containing the calculated value since the calculation is not a part of the model.
I'm using MVVM with Caliburn.Micro, but I think that's irrelevant since this seems to be a more general issue to me.