下面是来自我的 WPF 数据网格的 DataGridTextColumn 定义,其中包含转换器定义和转换器代码。有人可以请教我如何对这个专栏进行排序,我相信我需要使用 Icomparer,但是在尝试适应在线示例后,我的尝试失败了。如果你能在 VB.Net 中给出一个真正有帮助的解释 - 谢谢。
<Window.Resources>
<c:DurationConverter x:Key="MyDurationConverter"/>
<c:DistanceConverter x:Key="MyDistanceConverter"/>
</Window.Resources>
<DataGridTextColumn Header="Duration" Width="70" x:Name="Duration">
<DataGridTextColumn.Binding >
<MultiBinding Converter="{StaticResource MyDurationConverter}">
<Binding Path="StartDate" />
<Binding Path="EndDate"/>
<Binding Mode="OneWay" />
</MultiBinding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
Friend Class DurationConverter
Implements IMultiValueConverter
Friend Function Convert(values() As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IMultiValueConverter.Convert
Return (CType(values(1), DateTime) - CType(values(0), DateTime)).ToString
End Function
Friend Function ConvertBack(value As Object, targetTypes() As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object() Implements System.Windows.Data.IMultiValueConverter.ConvertBack
Throw New NotImplementedException
End Function
End Class