예제 #1
0
        /// <inheritdoc />
        public object?Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is bool inputValue))
            {
                throw new XamlParseException($"Input value has to be of type {nameof(Boolean)}").WithXmlLineInfo(m_serviceProvider);
            }
            if (TrueObject == null)
            {
                throw new XamlParseException($"{nameof(TrueObject)} can not be null").WithXmlLineInfo(m_serviceProvider);
            }
            if (FalseObject == null)
            {
                throw new XamlParseException($"{nameof(FalseObject)} can not be null").WithXmlLineInfo(m_serviceProvider);
            }
            if (TrueObject.GetType() != FalseObject.GetType())
            {
                throw new XamlParseException($"{nameof(TrueObject)} has to be the same type as {FalseObject}").WithXmlLineInfo(m_serviceProvider);
            }

            return(Inverted ? (inputValue) ? FalseObject : TrueObject : (inputValue) ? TrueObject : FalseObject);
        }
예제 #2
0
 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     return(TrueObject.Equals(value));
 }