text: ﻿//*********************************************************
  //
  // Copyright (c) Microsoft. All rights reserved.
  // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
  // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
  //
  //*********************************************************
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using Windows.UI;
  using Windows.UI.Xaml;
  using Windows.UI.Xaml.Data;
  using Windows.UI.Xaml.Media;
  
  namespace AppUIBasics.Common
  {
      /// <summary>
      /// Value converter that translates true to <see cref="Visibility.Visible"/> and false to
      /// <see cref="Visibility.Collapsed"/>.
      /// </summary>
      public sealed class ColorStringConverter : IValueConverter
      {
          public object Convert(object value, Type targetType, object parameter, string language)
          {
              if (value is Color)
              {
                  return ((Color)value).ToString();
              }
              else if (value is SolidColorBrush)
                  return (value as SolidColorBrush).Color.ToString();
              else
                  return "Unknown";
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, string language)
          {
              return Colors.Black;
          }
      }
  
  }
  