Files
DP44/Common/DTS.CommonCore/.svn/pristine/4a/4a9ff7a649ddd368bdbac7976ebe2b239f840187.svn-base

53 lines
1.7 KiB
Plaintext
Raw Normal View History

2026-04-17 14:55:32 -04:00
using System;
using System.Windows.Data;
using System.Windows;
namespace DTS.Common.Converters
{
public class VisibilityToRowHeightConverter : DependencyObject, IValueConverter
{
/// <summary>
/// inverts the source prior to conversion
/// </summary>
public bool InvertSource
{
get => (bool) GetValue(InvertSourceProperty);
set => SetValue(InvertSourceProperty, value);
}
public static readonly DependencyProperty InvertSourceProperty =
DependencyProperty.Register("InvertSource", typeof(bool), typeof(VisibilityToRowHeightConverter), new PropertyMetadata(false));
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is Visibility vis)
{
if (InvertSource)
{
switch (vis)
{
case Visibility.Visible:
vis = Visibility.Collapsed;
break;
case Visibility.Hidden:
case Visibility.Collapsed:
vis = Visibility.Visible;
break;
}
}
if (vis == Visibility.Collapsed)
{
return 0;
}
}
//return parameter;
return parameter ?? 0;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
}