|
15 | 15 | using DataGridExtensions.Framework; |
16 | 16 |
|
17 | 17 | using Throttle; |
| 18 | + using TomsToolbox.Wpf.Converters; |
| 19 | + using BooleanToVisibilityConverter = TomsToolbox.Wpf.Converters.BooleanToVisibilityConverter; |
18 | 20 |
|
19 | 21 | /// <summary> |
20 | 22 | /// This class is the control hosting all information needed for filtering of one column. |
|
24 | 26 | /// <seealso cref="INotifyPropertyChanged" /> |
25 | 27 | public class DataGridFilterColumnControl : Control, INotifyPropertyChanged |
26 | 28 | { |
27 | | - private static readonly BooleanToVisibilityConverter _booleanToVisibilityConverter = new BooleanToVisibilityConverter(); |
28 | 29 | private static readonly ControlTemplate _emptyControlTemplate = new ControlTemplate(); |
29 | 30 |
|
30 | 31 | private bool _getCellContentMustUseBinding; |
@@ -74,7 +75,23 @@ private void Self_Loaded(object sender, RoutedEventArgs e) |
74 | 75 | // Bind our IsFilterVisible and Template properties to the corresponding properties attached to the |
75 | 76 | // DataGridColumnHeader.Column property. Use binding instead of simple assignment since columnHeader.Column is still null at this point. |
76 | 77 | var isFilterVisiblePropertyPath = new PropertyPath("(0)", DataGridFilterColumn.IsFilterVisibleProperty); |
77 | | - BindingOperations.SetBinding(this, VisibilityProperty, new Binding() { Path = isFilterVisiblePropertyPath, Source = column, Mode = BindingMode.OneWay, Converter = _booleanToVisibilityConverter }); |
| 78 | + var isAutoFilterEnabledPropertyPath = new PropertyPath("(0)", DataGridFilter.IsAutoFilterEnabledProperty); |
| 79 | + |
| 80 | + BindingOperations.SetBinding(this, VisibilityProperty, new MultiBinding() |
| 81 | + { |
| 82 | + Converter = new CompositeMultiValueConverter() |
| 83 | + { |
| 84 | + MultiValueConverter = LogicalMultiValueConverter.And, |
| 85 | + Converters = { |
| 86 | + TomsToolbox.Wpf.Converters.BooleanToVisibilityConverter.Default |
| 87 | + } |
| 88 | + }, |
| 89 | + Bindings = |
| 90 | + { |
| 91 | + new Binding() { Path = isFilterVisiblePropertyPath, Source = column, Mode = BindingMode.OneWay }, |
| 92 | + new Binding() { Path = isAutoFilterEnabledPropertyPath, Source = DataGrid, Mode = BindingMode.OneWay } |
| 93 | + } |
| 94 | + }); ; |
78 | 95 |
|
79 | 96 | var templatePropertyPath = new PropertyPath("(0)", DataGridFilterColumn.TemplateProperty); |
80 | 97 | BindingOperations.SetBinding(this, TemplateProperty, new Binding() { Path = templatePropertyPath, Source = column, Mode = BindingMode.OneWay }); |
|
0 commit comments