11using CommunityToolkit . WinUI ;
2- using Microsoft . UI ;
32using Microsoft . UI . Xaml ;
43using Microsoft . UI . Xaml . Controls ;
54using Microsoft . UI . Xaml . Controls . Primitives ;
87using System ;
98using System . Collections ;
109using System . Collections . Generic ;
10+ using System . ComponentModel ;
1111using System . ComponentModel . DataAnnotations ;
1212using System . IO ;
1313using System . Linq ;
1919using Windows . Storage ;
2020using Windows . Storage . Pickers ;
2121using Windows . System ;
22- using WinRT . Interop ;
2322using WinUI . TableView . Extensions ;
2423using WinUI . TableView . Helpers ;
2524
@@ -49,12 +48,17 @@ public TableView()
4948
5049 Columns = new TableViewColumnsCollection ( this ) ;
5150 FilterHandler = new ColumnFilterHandler ( this ) ;
51+
5252 base . ItemsSource = _collectionView ;
5353 base . SelectionMode = SelectionMode ;
54+
55+ SetValue ( ConditionalCellStylesProperty , new TableViewConditionalCellStylesCollection ( ) ) ;
5456 RegisterPropertyChangedCallback ( ItemsControl . ItemsSourceProperty , OnBaseItemsSourceChanged ) ;
5557 RegisterPropertyChangedCallback ( ListViewBase . SelectionModeProperty , OnBaseSelectionModeChanged ) ;
58+
5659 Loaded += OnLoaded ;
5760 SelectionChanged += TableView_SelectionChanged ;
61+ _collectionView . ItemPropertyChanged += OnItemPropertyChanged ;
5862 }
5963
6064 /// <summary>
@@ -84,6 +88,16 @@ private void TableView_SelectionChanged(object sender, SelectionChangedEventArgs
8488 }
8589 }
8690
91+ /// <summary>
92+ /// Handles the PropertyChanged event of an item in the TableView.
93+ /// </summary>
94+ private void OnItemPropertyChanged ( object ? sender , PropertyChangedEventArgs e )
95+ {
96+ var row = ContainerFromItem ( sender ) as TableViewRow ;
97+
98+ row ? . EnsureCellsStyle ( default , sender ) ;
99+ }
100+
87101 /// <inheritdoc/>
88102 protected override void PrepareContainerForItemOverride ( DependencyObject element , object item )
89103 {
@@ -93,6 +107,7 @@ protected override void PrepareContainerForItemOverride(DependencyObject element
93107 {
94108 if ( element is TableViewRow row )
95109 {
110+ row . EnsureCellsStyle ( default , item ) ;
96111 row . ApplyCellsSelectionState ( ) ;
97112
98113 if ( CurrentCellSlot . HasValue )
@@ -739,8 +754,8 @@ private async Task<StorageFile> GetStorageFile()
739754 var savePicker = new FileSavePicker ( ) ;
740755 savePicker . FileTypeChoices . Add ( "CSV (Comma delimited)" , [ ".csv" ] ) ;
741756#if WINDOWS
742- var hWnd = Win32Interop . GetWindowFromWindowId ( XamlRoot . ContentIslandEnvironment . AppWindowId ) ;
743- InitializeWithWindow . Initialize ( savePicker , hWnd ) ;
757+ var hWnd = Microsoft . UI . Win32Interop . GetWindowFromWindowId ( XamlRoot . ContentIslandEnvironment . AppWindowId ) ;
758+ WinRT . Interop . InitializeWithWindow . Initialize ( savePicker , hWnd ) ;
744759#endif
745760
746761 return await savePicker . PickSaveFileAsync ( ) ;
0 commit comments