Click here to Skip to main content
15,893,368 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.8K   5.5K   44  
Dynamic data forms.
Namespace Controls
	Public Class MyCornerRadiusConverter
		Implements IValueConverter

		Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.Convert
			If TypeOf value Is CornerRadius AndAlso targetType = GetType(String) Then
				With DirectCast(value, CornerRadius)
					If .BottomLeft = .BottomRight AndAlso .BottomLeft = .TopLeft AndAlso .BottomLeft = .TopRight Then
						Return String.Format("{0}", .TopLeft)
					End If
					Return String.Format("{0},{1},{2},{3}", .TopLeft, .TopRight, .BottomRight, .BottomLeft)
				End With
			End If
			Return Nothing
		End Function

		Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
			If TypeOf value Is String And targetType Is GetType(CornerRadius) Then
				Dim parts() = Split(value, ",")
				If parts.Length = 1 Then
					Return New CornerRadius(Val(parts(0)))
				ElseIf parts.Length = 4 Then
					Return New CornerRadius(Val(parts(0)), Val(parts(1)), Val(parts(2)), Val(parts(3)))
				End If
			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