Comment faire pour que le premier élément d'un ListView xaml soit différent?
Ceci est pour une application Windows universelle.
Pouvez-vous me dire comment modifier uniquement le premier élément d'un ListView? J'ai essayé d'utiliser un modèle d'en-tête, mais je n'ai pas pu déterminer comment le lier au premier élément de ma liste des étapes.
La seule différence entre le premier élément et les autres éléments est que la forme du premier bord sera droite. Le premier élément n'aura pas ce style: Data = "M0,0 10,0 10,30 0,30 10,15"
MISE À JOUR: Je l'ai fait en utilisant un sélecteur de modèle (DataTemplateSelector). Cela signifie que je dois donner à chaque article un numéro de position. De meilleures solutions très appréciées!
Voici mon XAML:
<Page
x:Class="CloserCrumbs.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CloserCrumbs"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.DataContext>
<local:SuperVM />
</Page.DataContext>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView ItemsSource="{Binding Steps}" SelectedItem="{Binding Steps.SelectedItem, Mode=TwoWay}" Height="40" FocusVisualPrimaryThickness="0" FocusVisualSecondaryThickness="0">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="t1" Orientation="Horizontal" Margin="-12" Height="30">
<Grid Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Margin="0,0,-7,0" Height="30" >
<Path Data="M0,0 10,0 10,30 0,30 10,15" Fill="#d0d0d0" />
<Grid>
<Rectangle Fill="#d0d0d0" />
<TextBlock Text="{Binding ShortDescription}" Margin="10,5" VerticalAlignment="Center" Foreground="White" MinWidth="60"/>
</Grid>
<Path Data="M0,0 10,15 0,30" Fill="#d0d0d0" />
</StackPanel>
</Grid>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>