Hi,
I am trying to add calculated fields in XamDataGrid. From feature browser it seems that using UnBoundFields is a option (let me know if there are more).
Problem statement for me would be
public class Order : INPC {
public double Quantity {
get {return _qty;}
set { _qty = value; INPC("Quantity")}
}
public double CurrentPrice {
get {return _currentPx ; }
set {_currentPx = value ; INPC ("CurrentPrice")
/* fun starts here */
public double Notional {
get {return Quantity * CurrentPrice ;}
to have a calculated field (unsaid that i have a observableCollection<Order> and this is my dataSource and i have autogenerate col set to true)
Option #1 : Having a property Notional and raise its INPC when ever a dependent changes , this seems straight ; how ever for my use case i have lots of such calculated fields and some times the sources of values are cant be clubbed. This makes raising INPC difficult if not impossible. Also there is the part of registering dependencies of each calculated field.
Option #2 : add Notional as a unbound field in Grid and make it dependent on Columns 1 & 2 (qty , px) and let Grid handle it. Where it would calculate (based on a converter , event) and value is updated.
Before we spend effort and time on #1 , we wanted to find out if #2 is possible and more importantly is it performant (~10000 rows with , each column dependent on 2-3 fields , update rate of ~500 ms possible on dependent fields )
Please let me know if you need more details , thanks in advance.
The example suggested here is using Option #1 in the original post. I am more interested in Option #2, using IG Calculated Column feature.
I will create a new post.
Hi, this is a great question and example. However, I see that this original question still not answered: I have the same question.
Could you please answer this?
"To make things more clear in Option #2 we would be firing a INPC for all the source fields (in our case Qty and Px)
One addon question to this is , are calculations done on dispatcher or on background. and can we throttle the rate at which these calculations are triggered (if available)"
I have uploaded a sample that uses a MultiBinding to set the text in an UnboundField nased on a calculation of two other fields. The Style I declared is shown below:
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="CalcStyle1">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<TextBlock Name="Text1" Background="Yellow">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource SalaryConverter}">
<Binding Path="DataItem.EmployeeID"/>
<Binding Path="DataItem.Salary"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The sample is based on an Employee class, and I added unbound column which simply multiplies the employee ID by their salary, and is highlighted yellow. The "Cut Pay" button decrements the salary by one and the unbound field reflects that change.
I hope this is helpful...let me know if you have questions on this.
Hello,
I am looking into your inquiry...will post back as soon as I have more information.
Thanks,
To make things more clear in Option #2 we would be firing a INPC for all the source fields (in our case Qty and Px)
One addon question to this is , are calculations done on dispatcher or on background. and can we throttle the rate at which these calculations are triggered (if available)