Beispiel #1
0
        public static GapSize FromString(String str)
        {
            if (String.IsNullOrEmpty(str))
            {
                return(null);
            }
            var t     = new GapSize();
            var elems = str.Split(',');

            if (elems.Length == 1)
            {
                t.Vert = Length.FromString(elems[0]);
                t.Horz = t.Vert;
            }
            else if (elems.Length == 2)
            {
                t.Vert = Length.FromString(elems[0]);
                t.Horz = Length.FromString(elems[1]);
            }
            else
            {
                throw new XamlException($"Invalid Gap value '{str}'");
            }
            return(t);
        }
Beispiel #2
0
 public override Object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
 {
     if (value == null)
     {
         return(null);
     }
     if (value is String)
     {
         String strVal = value.ToString();
         return(GapSize.FromString(strVal));
     }
     throw new XamlException($"Invalid Gap value '{value}'");
 }