25 lines
901 B
C#
25 lines
901 B
C#
|
|
using System.Globalization;
|
||
|
|
using System.Windows;
|
||
|
|
using System.Windows.Data;
|
||
|
|
|
||
|
|
namespace TeamsISO.App.Converters;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Tiny utility converter — null or empty string ⇒ Collapsed, otherwise
|
||
|
|
/// Visible. Used by the v2 command palette's optional shortcut chip
|
||
|
|
/// (e.g. "Ctrl+R") so rows without a bound shortcut don't render the
|
||
|
|
/// empty pill outline.
|
||
|
|
/// </summary>
|
||
|
|
public sealed class NullToCollapsedConverter : IValueConverter
|
||
|
|
{
|
||
|
|
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
|
||
|
|
{
|
||
|
|
if (value is null) return Visibility.Collapsed;
|
||
|
|
if (value is string s && string.IsNullOrEmpty(s)) return Visibility.Collapsed;
|
||
|
|
return Visibility.Visible;
|
||
|
|
}
|
||
|
|
|
||
|
|
public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture) =>
|
||
|
|
System.Windows.Data.Binding.DoNothing;
|
||
|
|
}
|