小编Gai*_*oad的帖子

如何使xaml ListView中的第一项与众不同?

它看起来像什么,我需要什么

这适用于通用Windows应用程序.

请问您能告诉我如何仅修改ListView的第一个元素?我试图使用标题模板,但我无法弄清楚如何将它绑定到我的步骤列表中的第一个元素.

第一个元素和其他元素之间的唯一区别是第一个边缘的形状是直的.第一个元素没有这种样式:Data ="M0,0 10,0 10,30 0,30 10,15"

更新:我已经使用模板选择器(DataTemplateSelector).这意味着我必须给每个项目一个位置编号.更好的解决方案!

这是我的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 …
Run Code Online (Sandbox Code Playgroud)

xaml listview win-universal-app windows-10-universal uwp-xaml

2
推荐指数
1
解决办法
789
查看次数