maui-linux/Xamarin.Forms.Platform.WinRT/TextAlignmentToHorizontalAl...

48 строки
1.2 KiB
C#

using System;
using Windows.UI.Xaml;
#if WINDOWS_UWP
namespace Xamarin.Forms.Platform.UWP
#else
namespace Xamarin.Forms.Platform.WinRT
#endif
{
public sealed class TextAlignmentToHorizontalAlignmentConverter : Windows.UI.Xaml.Data.IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var alignment = (Windows.UI.Xaml.TextAlignment)value;
switch (alignment)
{
case Windows.UI.Xaml.TextAlignment.Center:
return HorizontalAlignment.Center;
case Windows.UI.Xaml.TextAlignment.Left:
return HorizontalAlignment.Left;
case Windows.UI.Xaml.TextAlignment.Right:
return HorizontalAlignment.Right;
default:
return HorizontalAlignment.Left;
}
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
var alignment = (HorizontalAlignment)value;
switch (alignment)
{
case HorizontalAlignment.Left:
return Windows.UI.Xaml.TextAlignment.Left;
case HorizontalAlignment.Center:
return Windows.UI.Xaml.TextAlignment.Center;
case HorizontalAlignment.Right:
return Windows.UI.Xaml.TextAlignment.Right;
default:
return Windows.UI.Xaml.TextAlignment.Left;
}
}
}
}