A clean way in WinUI 3 to show group headers visually in a GridView with a flat ItemsSource while keeping selection indexing clean is not directly built into the control. However, a recommended pattern involves these core ideas:
Use your flat ItemsSource but differentiate header items by a property or type.
Use a DataTemplateSelector to render header items visually distinct with non-selectable UI and partial span styles.
Make header items non-focusable and non-clickable by setting IsHitTestVisible=false.
Intercept selection and indexing logic events (like SelectionChanged or ItemClick) to filter out header items. You maintain a mapping from the GridView index to your underlying data index by skipping the header positions internally.
You can maintain a separate lookup (dictionary or list) in your ViewModel that maps displayed indices ignoring headers to true data indices, essentially creating a filtered index view. Use this mapping for all selection and manipulation logic so SelectedIndex maps correctly to your pure data items.
This approach avoids nested lists and CollectionViewSource, using a flat collection but requires manual mapping in code-behind or ViewModel when handling selection/indexing.
Additional tips:
Headers can be made visually distinct by using variable sized panels such as VariableSizedWrapGrid in the header DataTemplate to span the full width.
Using ContainerContentChanging to disable hit testing on headers is good but just stops interaction; index mapping still needs a manual approach.
You could override the GridView's SelectedIndex property indirectly by wrapping or intercepting selection events and converting them between flat and displayed indices.