如何在C#代码中设置转换器绑定?

时间:2011-07-28 10:32:43

标签: wpf data-binding wpftoolkit

我是WPF的新手,现在我在我的项目中使用第三方lib xamChart

以前在XAML中我有一个Chart,它的轴有一个 Unit,这是一个int 属性 我有

Unit="{Binding NextStartRow, Converter={StaticResource UnitConverter}}"

这很有效,但现在我需要通过后面的代码在运行时创建图表。 我怎么能在C#中做到这一点?和FYI所有的轴。在c#代码中的unix.xxx没有我想要的东西,请提前帮助,非常感谢,任何建议都非常感谢!

xaml中的FYI代码段

<igCA:Axis AxisType="PrimaryX" AutoRange="True"  
           Unit="{Binding AnotherIntegerProperty, Converter={StaticResource UnitConverter}}">

1 个答案:

答案 0 :(得分:25)

通过调整任何不正确的方法来尝试此操作,因为您错过了指定:

myXamChart.SetBinding(
  Unit,
  new Binding("AnotherIntegerProperty")
  {
    Converter = new UnitConverter()
  });

干杯