ListViewBase extensions
Warning
This docs page is outdated, please refer to the new one for the ListViewExtensions
type.
ListViewBase extensions provide a lightweight way to extend every control that inherits the ListViewBase class with attached properties.
AlternateColor
The AlternateColor property provides a way to assign a background color to every other item.
The ContainerContentChanging event used for this extension to work, will not be raised when the ItemsPanel is replaced with another type of panel than ItemsStackPanel or ItemsWrapGrid.
Example
<ListView
extensions:ListViewBase.AlternateColor="Silver"
ItemsSource="{x:Bind MainViewModel.Items, Mode=OneWay}" />
AlternateItemTemplate
The AlternateItemTemplate property provides a way to assign an alternate datatemplate to every other item. It is also possible to combine with the AlternateColor property.
The ContainerContentChanging event used for this extension to work, will not be raised when the ItemsPanel is replaced with another type of panel than ItemsStackPanel or ItemsWrapGrid.
Example
<Page.Resources>
<DataTemplate x:Name="NormalTemplate">
<TextBlock Text="{Binding }" Foreground="Green"></TextBlock>
</DataTemplate>
<DataTemplate x:Name="AlternateTemplate">
<TextBlock Text="{Binding }" Foreground="Orange"></TextBlock>
</DataTemplate>
</Page.Resources>
<ListView
ItemTemplate="{StaticResource NormalTemplate}"
extensions:ListViewBase.AlternateItemTemplate="{StaticResource AlternateTemplate}"
ItemsSource="{x:Bind MainViewModel.Items, Mode=OneWay}" />
StretchItemContainerDirection
The StretchItemContainerDirection property provides a way to stretch the ItemContainer in horizontal, vertical or both ways. Possible values for this property are Horizontal, Vertical and Both.
The ContainerContentChanging event used for this extension to work, will not be raised when the ItemsPanel is replaced with another type of panel than ItemsStackPanel or ItemsWrapGrid.
Example
<ListView
extensions:ListViewBase.StretchItemContainerDirection="Horizontal"
ItemsSource="{x:Bind MainViewModel.Items, Mode=OneWay}" />
Requirements (Windows 10 Device Family)
Device family | Universal, 10.0.14393.0 or higher |
---|---|
Namespace | Microsoft.Toolkit.Uwp.UI.Extensions |