Dim CalcManager As XamCalculationManager = New XamCalculationManager
Dim ShipRate As NamedReference () With {ReferenceId = "ShipRateRef", Value="0.05"}
Dim TaxRate As NamedReference () With {ReferenceId = "TaxRateRef", Value = "0.08" }
Dim ShipFactor As NamedReference () With {ReferenceId = "ShipFactorRef", Formula = "[ShipRateRef]+1"}
Dim TaxFactor As NamedReference () With {ReferenceId = "TaxFactorRef", Formula = "[TaxRateRef]+1" }
CalcManager.NamedReferences = New NamedReferenceCollectionCalcManager.NamedReferences.Add(ShipRate)
CalcManager.NamedReferences.Add(TaxRate)
CalcManager.NamedReferences.Add(ShipFactor)
CalcManager.NamedReferences.Add(TaxFactor)
Dim stackPanel As StackPanel = New StackPanel
Dim textbox1 As TextBox () With { Name="txtQuantity"}
XamCalculationManager.SetCalculationManager(textbox1, CalcManager)stackPanel.Children.Add(textbox1)
Dim textbox2 As TextBox () With { Name="txtPrice"}
XamCalculationManager.SetCalculationManager(textbox2, CalcManager)
stackPanel.Children.Add(textbox2)
Dim textblock1 As TextBlock = New TextBlock
Dim calcSettings As ControlCalculationSettings = New ControlCalculationSettings
'式は、 ShipFactor および TaxFactor の名前付き参照を使用
calcSettings.Formula = "[txtQuantity]*[txtPrice]*[ShipFactorRef]* [TaxFactorRef]"
XamCalculationManager.SetControlSettings(textblock1, calcSettings)
XamCalculationManager.SetCalculationManager(textblock1, CalcManager)
stackPanel.Children.Add(textblock1)