summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/TextAlignmentToHorizontalAlignmentConverter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/TextAlignmentToHorizontalAlignmentConverter.cs')
-rw-r--r--Xamarin.Forms.Platform.WinRT/TextAlignmentToHorizontalAlignmentConverter.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/TextAlignmentToHorizontalAlignmentConverter.cs b/Xamarin.Forms.Platform.WinRT/TextAlignmentToHorizontalAlignmentConverter.cs
new file mode 100644
index 00000000..8f95af1e
--- /dev/null
+++ b/Xamarin.Forms.Platform.WinRT/TextAlignmentToHorizontalAlignmentConverter.cs
@@ -0,0 +1,48 @@
+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;
+ }
+ }
+ }
+} \ No newline at end of file