From fb7831a4bb17a5d56e18edf0957e1d860ac4082f Mon Sep 17 00:00:00 2001 From: Steve Cadwallader Date: Sat, 14 Jan 2023 14:06:45 -0500 Subject: [PATCH] Multi-bind on IsVisibile to bypass a WPF leak issue --- CodeMaidShared/CodeMaidShared.projitems | 1 + .../UI/Converters/BooleanAndConverter.cs | 67 +++++++++++++++++++ .../BuildProgress/BuildProgressView.xaml | 21 +++--- 3 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 CodeMaidShared/UI/Converters/BooleanAndConverter.cs diff --git a/CodeMaidShared/CodeMaidShared.projitems b/CodeMaidShared/CodeMaidShared.projitems index 8fa3bac20..a9033ee27 100644 --- a/CodeMaidShared/CodeMaidShared.projitems +++ b/CodeMaidShared/CodeMaidShared.projitems @@ -159,6 +159,7 @@ True + diff --git a/CodeMaidShared/UI/Converters/BooleanAndConverter.cs b/CodeMaidShared/UI/Converters/BooleanAndConverter.cs new file mode 100644 index 000000000..d1aef97a8 --- /dev/null +++ b/CodeMaidShared/UI/Converters/BooleanAndConverter.cs @@ -0,0 +1,67 @@ +using System; +using System.Globalization; +using System.Linq; +using System.Windows.Data; + +namespace SteveCadwallader.CodeMaid.UI.Converters +{ + /// + /// A converter that performs a logical AND on all values. + /// + public class BooleanAndConverter : IMultiValueConverter + { + /// + /// The default . + /// + public static BooleanAndConverter Default = new BooleanAndConverter(); + + /// + /// Converts source values to a value for the binding target. The data binding engine calls + /// this method when it propagates the values from source bindings to the binding target. + /// + /// + /// The array of values that the source bindings in the produces. The value indicates that the source + /// binding has no value to provide for conversion. + /// + /// The type of the binding target property. + /// The converter parameter to use. + /// The culture to use in the converter. + /// + /// A converted value.If the method returns null, the valid null value is used.A return + /// value of . indicates that the converter + /// did not produce a value, and that the binding will use the if it is available, or else + /// will use the default value.A return value of . indicates that the binding + /// does not transfer the value or use the or the default value. + /// + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values == null || values.Length < 1) return null; + + return values.All(x => (bool)x); + } + + /// + /// Converts a binding target value to the source binding values. + /// + /// The value that the binding target produces. + /// + /// The array of types to convert to. The array length indicates the number and types of + /// values that are suggested for the method to return. + /// + /// The converter parameter to use. + /// The culture to use in the converter. + /// + /// An array of values that have been converted from the target value back to the source values. + /// + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/CodeMaidShared/UI/ToolWindows/BuildProgress/BuildProgressView.xaml b/CodeMaidShared/UI/ToolWindows/BuildProgress/BuildProgressView.xaml index aa6efaa4c..8d60c732f 100644 --- a/CodeMaidShared/UI/ToolWindows/BuildProgress/BuildProgressView.xaml +++ b/CodeMaidShared/UI/ToolWindows/BuildProgress/BuildProgressView.xaml @@ -1,10 +1,10 @@ @@ -13,8 +13,13 @@ - + + + + + + +