1
0
Fork 0
mirror of https://github.com/wagesj45/butterflow-ui.git synced 2024-11-12 21:03:34 -06:00
This commit is contained in:
Jordan Wages 2018-07-26 17:36:57 -05:00
parent df48c26af8
commit 6d41f96b1f
2 changed files with 46 additions and 0 deletions

View file

@ -9,9 +9,21 @@ using System.Windows.Data;
namespace butterflow_ui
{
/// <summary> A visibility converter. </summary>
[ValueConversion(typeof(bool), typeof(Visibility))]
public class BoolVisibilityConverter : IValueConverter
{
/// <summary> Converts a value. </summary>
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
/// type. </exception>
/// <param name="value"> The value produced by the binding source. </param>
/// <param name="targetType"> The type of the binding target property. </param>
/// <param name="parameter"> The converter parameter to use. </param>
/// <param name="culture"> The culture to use in the converter. </param>
/// <returns>
/// A converted value. If the method returns <see langword="null" />, the valid null value is
/// used.
/// </returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType == typeof(Visibility))
@ -22,6 +34,17 @@ namespace butterflow_ui
throw new InvalidCastException(string.Format("Cannot convert type to {0} from bool.", targetType.Name));
}
/// <summary> Converts a value. </summary>
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
/// type. </exception>
/// <param name="value"> The value that is produced by the binding target. </param>
/// <param name="targetType"> The type to convert to. </param>
/// <param name="parameter"> The converter parameter to use. </param>
/// <param name="culture"> The culture to use in the converter. </param>
/// <returns>
/// A converted value. If the method returns <see langword="null" />, the valid null value is
/// used.
/// </returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType == typeof(Visibility))

View file

@ -9,9 +9,21 @@ using System.Windows.Data;
namespace butterflow_ui
{
/// <summary> An inverse bool visibility converter. </summary>
[ValueConversion(typeof(bool), typeof(Visibility))]
public class InverseBoolVisibilityConverter : IValueConverter
{
/// <summary> Converts a value. </summary>
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
/// type. </exception>
/// <param name="value"> The value produced by the binding source. </param>
/// <param name="targetType"> The type of the binding target property. </param>
/// <param name="parameter"> The converter parameter to use. </param>
/// <param name="culture"> The culture to use in the converter. </param>
/// <returns>
/// A converted value. If the method returns <see langword="null" />, the valid null value is
/// used.
/// </returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType == typeof(Visibility))
@ -22,6 +34,17 @@ namespace butterflow_ui
throw new InvalidCastException(string.Format("Cannot convert type to {0} from bool.", targetType.Name));
}
/// <summary> Converts a value. </summary>
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
/// type. </exception>
/// <param name="value"> The value that is produced by the binding target. </param>
/// <param name="targetType"> The type to convert to. </param>
/// <param name="parameter"> The converter parameter to use. </param>
/// <param name="culture"> The culture to use in the converter. </param>
/// <returns>
/// A converted value. If the method returns <see langword="null" />, the valid null value is
/// used.
/// </returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType == typeof(Visibility))