[silverlight] 文字超過長度點點點(Convert)

  • 1381
  • 0

摘要:[silverlight] 文字超過長度點點點(Convert)

Imports System.Windows.Data
Public Class StringOverLengthConvert
    Implements IValueConverter

    Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert

        If Not IsNothing(value) Then
            If value.ToString().Length > 8 Then 
                value = value.ToString().Substring(0, 7) & ".."
            End If
        End If

        Return value
    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
        Return ""
    End Function
End Class