Skip to content

Commit 7a0ac50

Browse files
author
Anjali
committed
Added win11 styles for ListView and ListViewItem
1 parent 135e3b5 commit 7a0ac50

File tree

2 files changed

+83
-419
lines changed

2 files changed

+83
-419
lines changed

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Win11/Styles/ListView.xaml

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,69 @@
33
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
44
Copyright (C) Leszek Pomianowski and WPF UI Contributors.
55
All Rights Reserved.
6-
7-
Based on Microsoft XAML for Win UI
8-
Copyright (c) Microsoft Corporation. All Rights Reserved.
96
-->
107

11-
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
8+
<ResourceDictionary
9+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
10+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
1211

13-
<Style x:Key="DefaultListViewItemStyle" TargetType="{x:Type ListViewItem}">
14-
<Setter Property="Foreground" Value="{DynamicResource ListViewItemForeground}" />
15-
<Setter Property="Background" Value="Transparent" />
16-
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
17-
<Setter Property="Margin" Value="0,0,0,2" />
18-
<Setter Property="Padding" Value="4" />
12+
<Style x:Key="DefaultListViewStyle" TargetType="{x:Type ListView}">
13+
<Setter Property="Margin" Value="0" />
14+
<Setter Property="Padding" Value="0" />
15+
<Setter Property="BorderThickness" Value="0" />
16+
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
17+
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
18+
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
19+
<Setter Property="VerticalContentAlignment" Value="Center" />
20+
<Setter Property="VirtualizingPanel.IsVirtualizing" Value="True" />
21+
<Setter Property="VirtualizingPanel.VirtualizationMode" Value="Standard" />
22+
<Setter Property="SnapsToDevicePixels" Value="True" />
1923
<Setter Property="OverridesDefaultStyle" Value="True" />
24+
<Setter Property="ItemsPanel">
25+
<Setter.Value>
26+
<ItemsPanelTemplate>
27+
<VirtualizingStackPanel IsVirtualizing="{TemplateBinding VirtualizingPanel.IsVirtualizing}" VirtualizationMode="{TemplateBinding VirtualizingPanel.VirtualizationMode}" />
28+
</ItemsPanelTemplate>
29+
</Setter.Value>
30+
</Setter>
2031
<Setter Property="Template">
2132
<Setter.Value>
22-
<ControlTemplate TargetType="{x:Type ListBoxItem}">
23-
<Border
24-
x:Name="Border"
25-
Margin="0"
26-
Padding="0"
27-
Background="Transparent"
28-
BorderThickness="1"
29-
CornerRadius="{TemplateBinding Border.CornerRadius}">
30-
<Grid>
31-
<ContentPresenter Margin="{TemplateBinding Padding}" />
32-
<Rectangle
33-
x:Name="ActiveRectangle"
34-
Width="3"
35-
Height="18"
36-
Margin="0"
37-
HorizontalAlignment="Left"
38-
VerticalAlignment="Center"
39-
Fill="{DynamicResource ListViewItemPillFillBrush}"
40-
RadiusX="2"
41-
RadiusY="2"
42-
Visibility="Collapsed" />
43-
</Grid>
44-
</Border>
33+
<ControlTemplate TargetType="{x:Type ListView}">
34+
<Grid>
35+
<PassiveScrollViewer
36+
x:Name="PART_ContentHost"
37+
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
38+
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
39+
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
40+
<ItemsPresenter />
41+
</PassiveScrollViewer>
42+
<Rectangle
43+
x:Name="PART_DisabledVisual"
44+
Opacity="0"
45+
RadiusX="2"
46+
RadiusY="2"
47+
Stretch="Fill"
48+
Stroke="Transparent"
49+
StrokeThickness="0"
50+
Visibility="Collapsed">
51+
<Rectangle.Fill>
52+
<SolidColorBrush Color="{DynamicResource ControlFillColorDefault}" />
53+
</Rectangle.Fill>
54+
</Rectangle>
55+
</Grid>
4556
<ControlTemplate.Triggers>
46-
<MultiTrigger>
47-
<MultiTrigger.Conditions>
48-
<Condition Property="IsEnabled" Value="True" />
49-
<Condition Property="IsMouseOver" Value="True" />
50-
</MultiTrigger.Conditions>
51-
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemBackgroundPointerOver}" />
52-
53-
</MultiTrigger>
54-
<Trigger Property="IsSelected" Value="True">
55-
<Setter TargetName="ActiveRectangle" Property="Visibility" Value="Visible" />
56-
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemBackgroundPointerOver}" />
57+
<Trigger Property="IsGrouping" Value="True">
58+
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
59+
</Trigger>
60+
<Trigger Property="IsEnabled" Value="False">
61+
<Setter TargetName="PART_DisabledVisual" Property="Visibility" Value="Visible" />
5762
</Trigger>
5863
</ControlTemplate.Triggers>
5964
</ControlTemplate>
6065
</Setter.Value>
6166
</Setter>
6267
</Style>
6368

64-
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="{x:Type ListViewItem}" />
69+
<Style BasedOn="{StaticResource DefaultListViewStyle}" TargetType="{x:Type ListView}" />
6570

6671
</ResourceDictionary>

0 commit comments

Comments
 (0)