@@ -1821,27 +1821,35 @@ public View View
1821
1821
throw new NotSupportedException ( SR . ListViewCantSetViewToTileViewInVirtualMode ) ;
1822
1822
}
1823
1823
1824
- if ( _viewStyle ! = value )
1824
+ if ( _viewStyle = = value )
1825
1825
{
1826
- _viewStyle = value ;
1827
- if ( IsHandleCreated && Application . ComCtlSupportsVisualStyles )
1828
- {
1829
- PInvokeCore . SendMessage ( this , PInvoke . LVM_SETVIEW , ( WPARAM ) ( int ) _viewStyle ) ;
1830
- UpdateGroupView ( ) ;
1826
+ return ;
1827
+ }
1831
1828
1832
- // if we switched to Tile view we should update the win32 list view tile view info
1833
- if ( _viewStyle == View . Tile )
1834
- {
1835
- UpdateTileView ( ) ;
1836
- }
1837
- }
1838
- else
1829
+ _viewStyle = value ;
1830
+
1831
+ if ( IsHandleCreated && Application . ComCtlSupportsVisualStyles )
1832
+ {
1833
+ PInvokeCore . SendMessage ( this , PInvoke . LVM_SETVIEW , ( WPARAM ) ( int ) _viewStyle ) ;
1834
+ UpdateGroupView ( ) ;
1835
+
1836
+ // if we switched to Tile view we should update the win32 list view tile view info
1837
+ if ( _viewStyle == View . Tile )
1839
1838
{
1840
- UpdateStyles ( ) ;
1839
+ UpdateTileView ( ) ;
1841
1840
}
1841
+ }
1842
+ else
1843
+ {
1844
+ UpdateStyles ( ) ;
1845
+ }
1842
1846
1843
- UpdateListViewItemsLocations ( ) ;
1847
+ if ( IsHandleCreated && _viewStyle == View . Details )
1848
+ {
1849
+ ApplyColumnHeaderDarkModeOnDemand ( ) ;
1844
1850
}
1851
+
1852
+ UpdateListViewItemsLocations ( ) ;
1845
1853
}
1846
1854
}
1847
1855
@@ -4529,16 +4537,7 @@ protected override void OnHandleCreated(EventArgs e)
4529
4537
PInvokeCore . SendMessage ( this , PInvoke . CCM_SETVERSION , ( WPARAM ) 5 ) ;
4530
4538
}
4531
4539
4532
- #pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
4533
- if ( Application . IsDarkModeEnabled )
4534
- {
4535
- _ = PInvoke . SetWindowTheme ( HWND , $ "{ DarkModeIdentifier } _{ ExplorerThemeIdentifier } ", null ) ;
4536
-
4537
- // Get the ListView's ColumnHeader handle:
4538
- HWND columnHeaderHandle = ( HWND ) PInvokeCore . SendMessage ( this , PInvoke . LVM_GETHEADER , ( WPARAM ) 0 , ( LPARAM ) 0 ) ;
4539
- PInvoke . SetWindowTheme ( columnHeaderHandle , $ "{ DarkModeIdentifier } _{ ItemsViewThemeIdentifier } ", null ) ;
4540
- }
4541
- #pragma warning restore WFO5001
4540
+ ApplyColumnHeaderDarkModeOnDemand ( ) ;
4542
4541
4543
4542
UpdateExtendedStyles ( ) ;
4544
4543
RealizeProperties ( ) ;
@@ -4657,6 +4656,20 @@ protected override void OnHandleCreated(EventArgs e)
4657
4656
}
4658
4657
}
4659
4658
4659
+ private void ApplyColumnHeaderDarkModeOnDemand ( )
4660
+ {
4661
+ #pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
4662
+ if ( Application . IsDarkModeEnabled )
4663
+ {
4664
+ _ = PInvoke . SetWindowTheme ( HWND , $ "{ DarkModeIdentifier } _{ ExplorerThemeIdentifier } ", null ) ;
4665
+
4666
+ // Get the ListView's ColumnHeader handle:
4667
+ HWND columnHeaderHandle = ( HWND ) PInvokeCore . SendMessage ( this , PInvoke . LVM_GETHEADER , ( WPARAM ) 0 , ( LPARAM ) 0 ) ;
4668
+ PInvoke . SetWindowTheme ( columnHeaderHandle , $ "{ DarkModeIdentifier } _{ ItemsViewThemeIdentifier } ", null ) ;
4669
+ }
4670
+ #pragma warning restore WFO5001
4671
+ }
4672
+
4660
4673
protected override void OnHandleDestroyed ( EventArgs e )
4661
4674
{
4662
4675
// don't save the list view items state when in virtual mode : it is the responsibility of the
0 commit comments