Imports Windows.UI.Xaml.Data
Imports System
Imports C1.Chart

Public Class EnumToStringConverter
    Implements IValueConverter
    Public Function Convert(value As Object, targetType As Type, parameter As Object, language As String) As Object Implements IValueConverter.Convert
        Return value.ToString()
    End Function

    Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, language As String) As Object Implements IValueConverter.ConvertBack
        If targetType Is GetType(Position) Then
            Return CType([Enum].Parse(GetType(Position), value.ToString()), Position)
        Else
            Return CType([Enum].Parse(GetType(Palette), value.ToString()), Palette)
        End If
    End Function
End Class

Public Class StringToEnumConverter
    Implements IValueConverter
    Public Function Convert(value As Object, targetType As Type, parameter As Object, language As String) As Object Implements IValueConverter.Convert
        If targetType Is GetType(Position) Then
            Return CType([Enum].Parse(GetType(Position), value.ToString()), Position)
        End If

        Return Nothing
    End Function

    Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, language As String) As Object Implements IValueConverter.ConvertBack
        Throw New NotImplementedException()
    End Function
End Class