コード例 #1
0
 /// <summary>
 /// Converts the <see cref="Visibility"/> value to the proper <see cref="bool"/> value.
 /// </summary>
 /// <param name="value">The source data being passed to the target.</param>
 /// <param name="targetType">The <see cref="T:System.Type"/> of data expected by the target dependency property.</param>
 /// <param name="parameter">
 /// An optional parameter to be used in the converter logic.<br/>
 /// If it's equal to the "<c>not</c>" string, the conversion result is inverted.
 /// </param>
 /// <param name="culture">The culture of the conversion.</param>
 /// <returns>
 /// <paramref name="value"/> as a <see cref="bool"/>.
 /// </returns>
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(value is Visibility && BooleanToVisibilityConverter.ApplyModificator((Visibility)value == Visibility.Visible, parameter));
 }
コード例 #2
0
        /// <summary>
        /// Converts the <see cref="bool"/> value to the proper <see cref="Visibility"/> value.
        /// </summary>
        /// <param name="value">The source data being passed to the target.</param>
        /// <param name="targetType">The <see cref="T:System.Type"/> of data expected by the target dependency property.</param>
        /// <param name="parameter">
        /// An optional parameter to be used in the converter logic.<br/>
        /// If it's equal to the "<c>not</c>" string, the conversion result is inverted.
        /// </param>
        /// <param name="culture">The culture of the conversion.</param>
        /// <returns>
        /// <paramref name="value"/> as a <see cref="Visibility"/>.
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool flag = value is bool && (bool)value;

            return(BooleanToVisibilityConverter.ApplyModificator(flag, parameter) ? Visibility.Visible : Visibility.Collapsed);
        }