@@ -228,24 +228,33 @@ protected override void OnApplyTemplate()
228228 _optionsButton . Tapped += OnOptionsButtonTaped ;
229229 _optionsButton . DataContext = _optionsFlyoutViewModel = new OptionsFlyoutViewModel ( _tableView , this ) ;
230230
231- var menuItem = _optionsFlyout . Items . FirstOrDefault ( x => x . Name == "ItemsCheckFlyoutItem" ) ;
232- menuItem ? . ApplyTemplate ( ) ;
231+ if ( _optionsFlyout . Items . FirstOrDefault ( x => x . Name == "ItemsCheckFlyoutItem" ) is { } menuItem )
232+ {
233+ menuItem . Loaded += OnItemsCheckFlyoutItemLoaded ;
234+ }
235+
236+ SetFilterButtonVisibility ( ) ;
237+ EnsureGridLines ( ) ;
238+ }
239+
240+ /// <summary>
241+ /// Handles the Loaded event for the items check flyout item.
242+ /// </summary>
243+ private void OnItemsCheckFlyoutItemLoaded ( object sender , RoutedEventArgs e )
244+ {
245+ if ( sender is not MenuFlyoutItem menuItem ) return ;
246+
247+ menuItem . Loaded -= OnItemsCheckFlyoutItemLoaded ;
233248
234249 if ( menuItem ? . FindDescendant < CheckBox > ( x => x . Name == "SelectAllCheckBox" ) is { } checkBox )
235250 {
236251 _selectAllCheckBox = checkBox ;
237252 _selectAllCheckBox . Content = TableViewLocalizedStrings . SelectAllParenthesized ;
238253 _selectAllCheckBox . Checked += OnSelectAllCheckBoxChecked ;
239254 _selectAllCheckBox . Unchecked += OnSelectAllCheckBoxUnchecked ;
255+ _optionsFlyoutViewModel . SetSelectAllCheckBoxState ( ) ;
240256 }
241257
242- #if ! WINDOWS
243- if ( menuItem ? . FindDescendant < ListView > ( x => x . Name is "FilterItemsList" ) is { } filterItemsList )
244- {
245- filterItemsList . Margin = new Thickness ( 12 , 0 , 0 , 0 ) ;
246- }
247- #endif
248-
249258 if ( menuItem ? . FindDescendant < TextBox > ( x => x . Name == "SearchBox" ) is { } searchBox )
250259 {
251260 _searchBox = searchBox ;
@@ -259,9 +268,6 @@ protected override void OnApplyTemplate()
259268 // Handle Space key to prevent MenuFlyoutItem performing click action.
260269 menuItem . PreviewKeyUp += static ( _ , e ) => e . Handled = e . Key is VirtualKey . Space ;
261270 }
262-
263- SetFilterButtonVisibility ( ) ;
264- EnsureGridLines ( ) ;
265271 }
266272
267273 /// <summary>
0 commit comments