Click here to Skip to main content
15,897,718 members
Articles / Desktop Programming / WPF

CurionLib Dynamic Data Entry Forms

Rate me:
Please Sign up or sign in to vote.
5.00/5 (20 votes)
11 Aug 2013CPOL16 min read 54.9K   5.5K   44  
Dynamic data forms.
Namespace Controls
	Public Class StringTitleConverter
		Implements IValueConverter

		Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.Convert
			If targetType = GetType(String) AndAlso TypeOf value Is TextBlock Then
				Dim title As String = String.Empty
				With DirectCast(value, TextBlock)
					Select Case .TextAlignment
						Case TextAlignment.Left : title = "L,"
						Case TextAlignment.Right : title = "R,"
						Case TextAlignment.Center : title = "C,"
					End Select
					title += .Text
					Return title
				End With
			End If
			Return String.Empty
		End Function

		Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
			If targetType = GetType(FrameworkElement) AndAlso TypeOf value Is String Then
				Dim align = TextAlignment.Left
				Dim p = InStr(value, ",")
				If p > 0 Then
					Select Case LCase(value(0))
						Case "l" : align = TextAlignment.Left
						Case "r" : align = TextAlignment.Right
						Case "c" : align = TextAlignment.Center
					End Select
					value = Trim(Mid(value, p + 1))
				End If
				Return mSupport.StringTitle(value, align)
			End If
			Return Nothing
		End Function
	End Class
End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
I enjoy my wife, living in the woods, my 7 dogs, and learning new things. I like to play with UI stuff and model based coding.

Comments and Discussions