We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ValueConversion(typeof(bool?), typeof(Visibility))] public sealed class BoolToVisibilityConverter : IValueConverter { public static readonly BoolToVisibilityConverter VisibleWhenTrueElseCollapsed = new BoolToVisibilityConverter(Visibility.Visible, Visibility.Collapsed); public static readonly BoolToVisibilityConverter VisibleWhenTrueElseHidden = new BoolToVisibilityConverter(Visibility.Visible, Visibility.Hidden); private readonly object whenTrue; private readonly object whenFalse; public BoolToVisibilityConverter(Visibility whenTrue, Visibility whenFalse) { this.whenTrue = whenTrue; this.whenFalse = whenFalse; } public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value switch { true => this.whenTrue, false => this.whenFalse, null => this.whenFalse, _=> throw new ArgumentException("expected bool", nameof(value)), }; } object IValueConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new System.NotSupportedException($"{nameof(BoolToVisibilityConverter)} can only be used in OneWay bindings"); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: