Skip to content

Commit

Permalink
Add sample for ListViewExtensions.AlternateColor property
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlodotexe committed Nov 27, 2024
1 parent d36adbe commit 4fc769e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
9 changes: 1 addition & 8 deletions components/Extensions/samples/ListViewExtensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ The `AlternateColor` property provides a way to assign a background color to eve
Here is how this property can be used in XAML:

```xaml
<Page ...
xmlns:ui="using:CommunityToolkit.WinUI">

<ListView
ui:ListViewExtensions.AlternateColor="Silver"
ItemsSource="{x:Bind MainViewModel.Items, Mode=OneWay}" />
```
> [!SAMPLE ListViewExtensionsAlternateColorSample]
## AlternateItemTemplate

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Page x:Class="ExtensionsExperiment.Samples.ListViewExtensionsAlternateColorSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="using:CommunityToolkit.WinUI"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<ListView ui:ListViewExtensions.AlternateColor="Silver">
<ListView.Items>
<x:String>One</x:String>
<x:String>Two</x:String>
<x:String>Three</x:String>
<x:String>Four</x:String>
<x:String>Five</x:String>
<x:String>Six</x:String>
<x:String>Seven</x:String>
<x:String>Eight</x:String>
<x:String>Nine</x:String>
<x:String>Ten</x:String>
</ListView.Items>
</ListView>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace ExtensionsExperiment.Samples;

/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
[ToolkitSample(id: nameof(ListViewExtensionsAlternateColorSample), nameof(ListViewExtensionsAlternateColorSample), description: $"A sample for showing how to use the ListViewExtensions.AlternateColor attached property.")]
public sealed partial class ListViewExtensionsAlternateColorSample : Page
{
public ListViewExtensionsAlternateColorSample()
{
this.InitializeComponent();
}
}

0 comments on commit 4fc769e

Please sign in to comment.