Skip to content

Commit 4fc769e

Browse files
committed
Add sample for ListViewExtensions.AlternateColor property
1 parent d36adbe commit 4fc769e

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

components/Extensions/samples/ListViewExtensions.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ The `AlternateColor` property provides a way to assign a background color to eve
3131
3232
Here is how this property can be used in XAML:
3333

34-
```xaml
35-
<Page ...
36-
xmlns:ui="using:CommunityToolkit.WinUI">
37-
38-
<ListView
39-
ui:ListViewExtensions.AlternateColor="Silver"
40-
ItemsSource="{x:Bind MainViewModel.Items, Mode=OneWay}" />
41-
```
34+
> [!SAMPLE ListViewExtensionsAlternateColorSample]
4235
4336
## AlternateItemTemplate
4437

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Page x:Class="ExtensionsExperiment.Samples.ListViewExtensionsAlternateColorSample"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:ui="using:CommunityToolkit.WinUI"
5+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
6+
7+
<ListView ui:ListViewExtensions.AlternateColor="Silver">
8+
<ListView.Items>
9+
<x:String>One</x:String>
10+
<x:String>Two</x:String>
11+
<x:String>Three</x:String>
12+
<x:String>Four</x:String>
13+
<x:String>Five</x:String>
14+
<x:String>Six</x:String>
15+
<x:String>Seven</x:String>
16+
<x:String>Eight</x:String>
17+
<x:String>Nine</x:String>
18+
<x:String>Ten</x:String>
19+
</ListView.Items>
20+
</ListView>
21+
</Page>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace ExtensionsExperiment.Samples;
6+
7+
/// <summary>
8+
/// An empty page that can be used on its own or navigated to within a Frame.
9+
/// </summary>
10+
[ToolkitSample(id: nameof(ListViewExtensionsAlternateColorSample), nameof(ListViewExtensionsAlternateColorSample), description: $"A sample for showing how to use the ListViewExtensions.AlternateColor attached property.")]
11+
public sealed partial class ListViewExtensionsAlternateColorSample : Page
12+
{
13+
public ListViewExtensionsAlternateColorSample()
14+
{
15+
this.InitializeComponent();
16+
}
17+
}

0 commit comments

Comments
 (0)