|
| 1 | +<UserControl x:Class="UITests.Shared.Windows_UI_Xaml_Controls.ListView.ListView_Multiple_Templates" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:local="using:UITests.Shared.Windows_UI_Xaml_Controls.ListView" |
| 5 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 6 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 7 | + mc:Ignorable="d" |
| 8 | + d:DesignHeight="600" |
| 9 | + d:DesignWidth="400"> |
| 10 | + |
| 11 | + <UserControl.Resources> |
| 12 | + |
| 13 | + <!-- Template 1: Sub-header / category label (gray small text) --> |
| 14 | + <DataTemplate x:Key="SubHeaderTemplate"> |
| 15 | + <TextBlock Text="{Binding Label}" |
| 16 | + Foreground="#888888" |
| 17 | + FontSize="12" |
| 18 | + Margin="16,12,16,4" /> |
| 19 | + </DataTemplate> |
| 20 | + |
| 21 | + <!-- Template 2: High-priority item – yellow/gold left accent border --> |
| 22 | + <DataTemplate x:Key="HighPriorityTemplate"> |
| 23 | + <Grid Margin="12,4,12,4"> |
| 24 | + <Border Background="White" |
| 25 | + CornerRadius="8" |
| 26 | + Padding="0"> |
| 27 | + <Border.Shadow> |
| 28 | + <ThemeShadow /> |
| 29 | + </Border.Shadow> |
| 30 | + <Grid> |
| 31 | + <Grid.ColumnDefinitions> |
| 32 | + <ColumnDefinition Width="4" /> |
| 33 | + <ColumnDefinition Width="*" /> |
| 34 | + </Grid.ColumnDefinitions> |
| 35 | + <Rectangle Grid.Column="0" |
| 36 | + Fill="#E6A817" |
| 37 | + RadiusX="8" |
| 38 | + RadiusY="8" /> |
| 39 | + <TextBlock Grid.Column="1" |
| 40 | + Text="{Binding Label}" |
| 41 | + Margin="14,14,14,14" |
| 42 | + FontSize="15" |
| 43 | + Foreground="#1A1A2E" /> |
| 44 | + </Grid> |
| 45 | + </Border> |
| 46 | + </Grid> |
| 47 | + </DataTemplate> |
| 48 | + |
| 49 | + <!-- Template 3: Adaptive item – teal left accent border --> |
| 50 | + <DataTemplate x:Key="AdaptiveTemplate"> |
| 51 | + <Grid Margin="12,4,12,4"> |
| 52 | + <Border Background="White" |
| 53 | + CornerRadius="8" |
| 54 | + Padding="0"> |
| 55 | + <Grid> |
| 56 | + <Grid.ColumnDefinitions> |
| 57 | + <ColumnDefinition Width="4" /> |
| 58 | + <ColumnDefinition Width="*" /> |
| 59 | + </Grid.ColumnDefinitions> |
| 60 | + <Rectangle Grid.Column="0" |
| 61 | + Fill="#2EC4B6" |
| 62 | + RadiusX="8" |
| 63 | + RadiusY="8" /> |
| 64 | + <TextBlock Grid.Column="1" |
| 65 | + Text="{Binding Label}" |
| 66 | + Margin="14,14,14,14" |
| 67 | + FontSize="15" |
| 68 | + Foreground="#1A1A2E" /> |
| 69 | + </Grid> |
| 70 | + </Border> |
| 71 | + </Grid> |
| 72 | + </DataTemplate> |
| 73 | + |
| 74 | + <!-- Template 4: Badge item – shows a count badge on the right --> |
| 75 | + <DataTemplate x:Key="BadgeTemplate"> |
| 76 | + <Grid Margin="12,4,12,4"> |
| 77 | + <Border Background="White" |
| 78 | + CornerRadius="8" |
| 79 | + Padding="0"> |
| 80 | + <Grid> |
| 81 | + <Grid.ColumnDefinitions> |
| 82 | + <ColumnDefinition Width="4" /> |
| 83 | + <ColumnDefinition Width="*" /> |
| 84 | + <ColumnDefinition Width="Auto" /> |
| 85 | + </Grid.ColumnDefinitions> |
| 86 | + <Rectangle Grid.Column="0" |
| 87 | + Fill="#7B5EA7" |
| 88 | + RadiusX="8" |
| 89 | + RadiusY="8" /> |
| 90 | + <TextBlock Grid.Column="1" |
| 91 | + Text="{Binding Label}" |
| 92 | + Margin="14,14,8,14" |
| 93 | + FontSize="15" |
| 94 | + Foreground="#1A1A2E" /> |
| 95 | + <Border Grid.Column="2" |
| 96 | + Background="#7B5EA7" |
| 97 | + CornerRadius="12" |
| 98 | + Margin="0,10,12,10" |
| 99 | + Padding="8,2"> |
| 100 | + <TextBlock Text="{Binding Badge}" |
| 101 | + Foreground="White" |
| 102 | + FontSize="12" |
| 103 | + FontWeight="Bold" /> |
| 104 | + </Border> |
| 105 | + </Grid> |
| 106 | + </Border> |
| 107 | + </Grid> |
| 108 | + </DataTemplate> |
| 109 | + |
| 110 | + <!-- Template 5: Maintenance / plain item – blue-grey left accent --> |
| 111 | + <DataTemplate x:Key="MaintenanceTemplate"> |
| 112 | + <Grid Margin="12,4,12,4"> |
| 113 | + <Border Background="White" |
| 114 | + CornerRadius="8" |
| 115 | + Padding="0"> |
| 116 | + <Grid> |
| 117 | + <Grid.ColumnDefinitions> |
| 118 | + <ColumnDefinition Width="4" /> |
| 119 | + <ColumnDefinition Width="*" /> |
| 120 | + </Grid.ColumnDefinitions> |
| 121 | + <Rectangle Grid.Column="0" |
| 122 | + Fill="#4A90D9" |
| 123 | + RadiusX="8" |
| 124 | + RadiusY="8" /> |
| 125 | + <StackPanel Grid.Column="1" |
| 126 | + Margin="14,10,14,10"> |
| 127 | + <TextBlock Text="{Binding Label}" |
| 128 | + FontSize="15" |
| 129 | + Foreground="#1A1A2E" /> |
| 130 | + <TextBlock Text="{Binding SubText}" |
| 131 | + FontSize="11" |
| 132 | + Foreground="#777" |
| 133 | + Visibility="{Binding HasSubText}" /> |
| 134 | + </StackPanel> |
| 135 | + </Grid> |
| 136 | + </Border> |
| 137 | + </Grid> |
| 138 | + </DataTemplate> |
| 139 | + |
| 140 | + <!-- Template Selector --> |
| 141 | + <local:SessionItemTemplateSelector x:Key="TemplateSelector" |
| 142 | + SubHeaderTemplate="{StaticResource SubHeaderTemplate}" |
| 143 | + HighPriorityTemplate="{StaticResource HighPriorityTemplate}" |
| 144 | + AdaptiveTemplate="{StaticResource AdaptiveTemplate}" |
| 145 | + BadgeTemplate="{StaticResource BadgeTemplate}" |
| 146 | + MaintenanceTemplate="{StaticResource MaintenanceTemplate}" /> |
| 147 | + |
| 148 | + <!-- Group header style --> |
| 149 | + <Style x:Key="GroupHeaderStyle" |
| 150 | + TargetType="ListViewHeaderItem"> |
| 151 | + <Setter Property="HorizontalContentAlignment" |
| 152 | + Value="Stretch" /> |
| 153 | + <Setter Property="Padding" |
| 154 | + Value="0" /> |
| 155 | + </Style> |
| 156 | + |
| 157 | + <!-- ListViewItem strip chrome --> |
| 158 | + <Style x:Key="SessionListViewItemStyle" |
| 159 | + TargetType="ListViewItem"> |
| 160 | + <Setter Property="Padding" |
| 161 | + Value="0" /> |
| 162 | + <Setter Property="Margin" |
| 163 | + Value="0" /> |
| 164 | + <Setter Property="HorizontalContentAlignment" |
| 165 | + Value="Stretch" /> |
| 166 | + <Setter Property="MinHeight" |
| 167 | + Value="0" /> |
| 168 | + </Style> |
| 169 | + |
| 170 | + <CollectionViewSource x:Key="GroupedSource" |
| 171 | + x:Name="GroupedSource" |
| 172 | + IsSourceGrouped="True" /> |
| 173 | + |
| 174 | + </UserControl.Resources> |
| 175 | + |
| 176 | + <Grid Background="#F0F0F7"> |
| 177 | + <Grid.RowDefinitions> |
| 178 | + <RowDefinition Height="Auto" /> |
| 179 | + <RowDefinition Height="*" /> |
| 180 | + </Grid.RowDefinitions> |
| 181 | + |
| 182 | + <!-- Title bar --> |
| 183 | + <Border Grid.Row="0" |
| 184 | + Background="#3A3A8C" |
| 185 | + Padding="16,20,16,20"> |
| 186 | + <TextBlock Text="Session Details" |
| 187 | + Foreground="White" |
| 188 | + FontSize="20" |
| 189 | + FontWeight="Bold" |
| 190 | + HorizontalAlignment="Center" /> |
| 191 | + </Border> |
| 192 | + |
| 193 | + <!-- Grouped ListView --> |
| 194 | + <ListView x:Name="SessionListView" |
| 195 | + Grid.Row="1" |
| 196 | + ItemsSource="{Binding Source={StaticResource GroupedSource}}" |
| 197 | + ItemTemplateSelector="{StaticResource TemplateSelector}" |
| 198 | + ItemContainerStyle="{StaticResource SessionListViewItemStyle}" |
| 199 | + SelectionMode="None" |
| 200 | + IsItemClickEnabled="True"> |
| 201 | + |
| 202 | + <ListView.ItemsPanel> |
| 203 | + <ItemsPanelTemplate> |
| 204 | + <ItemsStackPanel GroupHeaderPlacement="Top" /> |
| 205 | + </ItemsPanelTemplate> |
| 206 | + </ListView.ItemsPanel> |
| 207 | + |
| 208 | + <ListView.GroupStyle> |
| 209 | + <GroupStyle HeaderContainerStyle="{StaticResource GroupHeaderStyle}"> |
| 210 | + <GroupStyle.HeaderTemplate> |
| 211 | + <DataTemplate> |
| 212 | + <StackPanel Margin="12,18,12,4"> |
| 213 | + <TextBlock Text="{Binding Key}" |
| 214 | + FontSize="13" |
| 215 | + FontWeight="Bold" |
| 216 | + Foreground="#1A1A2E" |
| 217 | + CharacterSpacing="100" /> |
| 218 | + <TextBlock Text="{Binding SubTitle}" |
| 219 | + FontSize="11" |
| 220 | + Foreground="#999999" |
| 221 | + Margin="0,1,0,0" /> |
| 222 | + </StackPanel> |
| 223 | + </DataTemplate> |
| 224 | + </GroupStyle.HeaderTemplate> |
| 225 | + </GroupStyle> |
| 226 | + </ListView.GroupStyle> |
| 227 | + </ListView> |
| 228 | + |
| 229 | + </Grid> |
| 230 | + |
| 231 | +</UserControl> |
0 commit comments