使用WPF将MultiBinding的DataGridTextColumn转换为telerik

时间:2013-09-11 20:09:53

标签: wpf telerik wpf-controls wpftoolkit

  <DataGridTextColumn Header="Total"  Width="SizeToHeader" IsReadOnly="True">
      <DataGridTextColumn.Binding>
        <MultiBinding Converter="{StaticResource testname}">
             <Binding Path="test1"/>
             <Binding Path="test2"/>
        </MultiBinding>
      </DataGridTextColumn.Binding>
  </DataGridTextColumn>

public class testnameConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        int dose = 0;
        int waste = 0;

        Int32.TryParse(values[0].ToString(), out dose);
        Int32.TryParse(values[1].ToString(), out waste);

        int total = dose + waste;

        return total.ToString();
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotSupportedException();
    }
}

我想知道如何将DataGridTextColumn转换为telerik,因为telerik不支持telerik:GridViewDataColumn.Binding。有人可以告诉我如何使用我的转换器。

1 个答案:

答案 0 :(得分:2)

  <telerik:GridViewDataColumn.CellTemplate>
     <DataTemplate>
         <TextBlock>
             <TextBlock.Text>
                <MultiBinding Converter="{StaticResource testname}">
                    <Binding Path="test1"/>
                    <Binding Path="test2"/>
                </MultiBinding>
             </TextBlock.Text>
         </TextBlock>
     </DataTemplate>
  </telerik:GridViewDataColumn.CellTemplate>