为LongListSelector的各个项添加边框

本文关键字:添加 边框 LongListSelector | 更新日期: 2023-09-27 17:50:11

我试图在longlistselector的每个项目周围使用边界来区分单个项目。我尝试添加BorderThickness属性到我的longlistselector,但它没有在我的列表项周围给出任何边界。

这是我的xaml文件

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
   <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"/>    
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <phone:LongListSelector HorizontalAlignment="Stretch" x:Name="lls_Text_SelectionList" ItemsSource="{Binding }" FontSize="36" Margin="0,10,0,88" HideEmptyGroups="True"  Background="Gray" BorderBrush="Red" BorderThickness="10" />
    </Grid>
</Grid>

我已经使用了各种值BorderThicknessBorderBrush,但它给我没有边界。有人能帮我解决这个问题吗?

为LongListSelector的各个项添加边框

您需要一个ItemTemplate。像这样:

<phone:LongListSelector HorizontalAlignment="Stretch" x:Name="lls_Text_SelectionList" ItemsSource="{Binding }" " Margin="0,10,0,88" HideEmptyGroups="True"  Background="Gray" >   
  <phone:LongListSelector.ItemTemplate>
    <DataTemplate>
        <Border BorderBrush="Red" BorderThickness="10">
          <TextBlock Text="{Binding}"  Style="{StaticResource PhoneTextLargeStyle}" />
        </Border>
    </DataTemplate>
  </phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>