36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
using System;
|
|
using System.Windows.Data;
|
|
|
|
namespace DTS.Common.Converters
|
|
{
|
|
|
|
/// <summary>
|
|
/// Represents the converter that converts Boolean values to Opacity value.
|
|
/// Use the BooleanToOpacityConverter class to convert a Boolean to Opacity value to provide visual feedback to the user if control enable or disable.
|
|
/// </summary>
|
|
public class BooleanToOpacityConverter : IValueConverter
|
|
{
|
|
/// <summary>
|
|
/// Converts a Boolean value to a Opacity to show user control enable/disable.
|
|
/// </summary>
|
|
/// <param name="value">The Boolean value to convert. This value can be a standard Boolean value or a nullable Boolean value.</param>
|
|
/// <param name="targetType">This parameter is not used.</param>
|
|
/// <param name="parameter">The converter parameter to use.</param>
|
|
/// <param name="culture">This parameter is not used.</param>
|
|
/// <returns>The value to be passed to the target dependency property.</returns>
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
|
|
if (value != null && (bool)value)
|
|
return 0.5;
|
|
return 1;
|
|
}
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|