diff --git a/src/Controls/TableViewFilterItemsControl.xaml.cs b/src/Controls/TableViewFilterItemsControl.xaml.cs index 50b2c42c..16d553c9 100644 --- a/src/Controls/TableViewFilterItemsControl.xaml.cs +++ b/src/Controls/TableViewFilterItemsControl.xaml.cs @@ -49,10 +49,7 @@ internal async void Initialize() /// internal void ClearSearchBox() { - if (searchBox is not null) - { - searchBox.Text = string.Empty; - } + searchBox?.Text = string.Empty; } private void OnSearchBoxTextChanged(object sender, TextChangedEventArgs e) @@ -67,7 +64,8 @@ private void OnSearchBoxKeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter && searchBox?.Text.Length > 0) { - ColumnHeader?.ExecuteOkCommand(); + ColumnHeader?.HideFlyout(); + ColumnHeader?.ApplyFilter(); e.Handled = true; } @@ -175,7 +173,19 @@ internal ICollection? FilterItems /// /// Gets or sets the column header associated with the filter items control. /// - public TableViewColumnHeader? ColumnHeader { get; internal set; } + public TableViewColumnHeader? ColumnHeader + { + get; + set + { + if (value is { FilterItemsControl: null }) + { + value.FilterItemsControl = this; + } + + field = value; + } + } /// /// Gets or sets the TableView associated with the filter items control. diff --git a/src/TableViewColumnHeader.OptionComamnds.cs b/src/TableViewColumnHeader.OptionComamnds.cs index fb78faca..99d4f6a3 100644 --- a/src/TableViewColumnHeader.OptionComamnds.cs +++ b/src/TableViewColumnHeader.OptionComamnds.cs @@ -1,6 +1,5 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; -using WinUI.TableView.Extensions; using SD = WinUI.TableView.SortDirection; namespace WinUI.TableView; @@ -11,9 +10,7 @@ partial class TableViewColumnHeader private readonly StandardUICommand _sortAscendingCommand = new() { Label = TableViewLocalizedStrings.SortAscending }; private readonly StandardUICommand _sortDescendingCommand = new() { Label = TableViewLocalizedStrings.SortDescending }; private readonly StandardUICommand _clearSortingCommand = new() { Label = TableViewLocalizedStrings.ClearSorting }; - private readonly StandardUICommand _clearFilterCommand = new() { Label = TableViewLocalizedStrings.ClearFilter }; - private readonly StandardUICommand _okCommand = new() { Label = TableViewLocalizedStrings.Ok }; - private readonly StandardUICommand _cancelCommand = new() { Label = TableViewLocalizedStrings.Cancel }; + private readonly StandardUICommand _clearFilterCommand = new() { Label = TableViewLocalizedStrings.ClearFilter }; /// /// Sets commands to option menu items. @@ -30,15 +27,6 @@ private void SetOptionCommands() clearSortingMenuItem.Command = _clearSortingCommand; if (GetTemplateChild("ClearFilterMenuItem") is MenuFlyoutItem clearFilterMenuItem) clearFilterMenuItem.Command = _clearFilterCommand; - if (GetTemplateChild("ActionButtonsMenuItem") is MenuFlyoutItem actionButtonsMenuItem) - { - actionButtonsMenuItem.ApplyTemplate(); - - if (actionButtonsMenuItem.FindDescendant