Your
ItemsSource
is looking for a property called "ProductPrice", but the view-model property is called "ProductPrice
s". I assume that's just a typo in your question?
The
ProductPrices
property looks odd - you're clearing and resetting the
DataTable
every time the property is accessed.
You're also using an instance of your model to read the price, but in the code you've posted, the price is never updated. Have you just omitted some of the code?
The main problem is most likely the bindings on the grid columns, which haven't been set:
<DataGridTextColumn Binding="{x:Null}" ...
These need to be set to proper bindings for the columns you want to display:
<DataGridTextColumn Binding="{Binding Path='Product Key'}" ... />
<DataGridTextColumn Binding="{Binding Path=Price}" ... />
NB: To bind to a column name that contains a space, you need to wrap the name in single quotes. Since the name isn't displayed anywhere, it would be easier to rename the column to
ProductKey
, without the space.
The code you've posted also has the
DataGrid.Columns
outside of the
DataGrid
tag. I assume that's another typo?