Once I got past my silly mistakes and was able to get a DataGridUnboundItemProperty to hit my event handler for QueryValue, I found that I only ever receive an EmptyDataItem as e.Item, instead of a DataRowView as all the examples I have found indicate. Of course, I can't calulate much with only an EmptyDataItem. The first column shows up fine, I just can't get to the data to calculate the second.
Any help in pointing me in the right direction would be greatly appreciated.
In case it matters, I'm using the TableFlowView.
Below is the declaration of the DataGridCollectionViewSource:
<xcdg:DataGridCollectionViewSource x:Key="cvsInvoices" Source="{Binding ElementName=root, Path=Invoices}" AutoCreateItemProperties="False">
<xcdg:DataGridCollectionViewSource.ItemProperties>
<xcdg:DataGridItemProperty Name="Invoice_Number" Title="Invoice Num"/>
<xcdg:DataGridUnboundItemProperty Name="Total_Cost" Title="Cost" DataType="sys:String" QueryValue="OnQueryValueTotalCost"/>
</xcdg:DataGridCollectionViewSource.ItemProperties>
</xcdg:DataGridCollectionViewSource>
And the definition of the QueryValue event handler:
private void OnQueryValueTotalCost( object sender, DataGridItemPropertyQueryValueEventArgs e )
{
var _row = e.Item as DataRowView;
if( _row == null || _row["Invoice_ID"] == DBNull.Value )
e.Value =
string.Empty;
else
{
int _iInvId = (int)_row["Invoice_ID"];
}
}