我有一个带有ComboboxEdit CellTemplate的两列的Devexpress DxGrid
<dxg:GridControl Name="grid">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Size_ID" CellTemplate="{DynamicResource DimensionComboBox}"/>
<dxg:GridColumn FieldName="Color_ID" CellTemplate="{DynamicResource DimensionComboBox}"/>
</dxg:GridControl.Columns>
</dxg:GridControl>
在我的app.xaml中我定义了一个模板
<DataTemplate x:Key="DimensionComboBox" >
<dxe:ComboBoxEdit x:Name="PART_Editor" DisplayMember="Grp_Property_Desc" ValueMember="Grp_Property_ID" >
<dxe:ComboBoxEdit.ItemsSource>
<Binding Path="Data">
<Binding.Converter>
<local:GridComboBoxItemSourceConverter/>
</Binding.Converter>
</Binding>
</dxe:ComboBoxEdit.ItemsSource>
</dxe:ComboBoxEdit>
</DataTemplate>
我想知道我的转换器中的列字段名称,以便我根据调用转换器的列返回数据
Public Class GridComboBoxItemSourceConverter
Implements IValueConverter
#Region "IValueConverter Members"
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
'if field name is color_id then return data for color_id
'if field name is size_id then return data for size_id
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function
#End Region
End Class
有没有办法在不必为每列创建转换器类的情况下完成此操作,我还有许多其他要转换的列。
答案 0 :(得分:1)
您可以为每列创建数据窗口,并在转换器参数
中指定列名称