问题
I Have a LongListSelector which is bonded to a contact list , i would like to add a little line to separate each contacts .
Here is my xaml :
<phone:LongListSelector>
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation = "Horizontal" >
<TextBlock Text="{Binding informations}" Height="120" />
<Image Source="{Binding photo}" Height="90" Width="90" />
<Line Fill="Red" Height="2" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
But there is no red line between the items, how can I add one?
EDIT :
Does it have to do with the fact that the orientation of my StackPanel is Horizontal?
回答1:
Yes, it's because of the "Horizontal".
Try this:
<phone:LongListSelector>
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation = "Horizontal" >
<TextBlock Text="{Binding informations}" Height="120" />
<Image Source="{Binding photo}" Height="90" Width="90" />
</StackPanel>
<Line Fill="Red" Height="2" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
回答2:
In my case the above solution didn't work so here is an alternate solution:
<phone:LongListSelector>
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel>
<TextBlock Text="{Binding informations}" Height="120" />
<Image Source="{Binding photo}" Height="90" Width="90" />
</StackPanel>
<Rectange Fill="Red" Height="2" width="120"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
来源:https://stackoverflow.com/questions/20940716/separator-between-items-in-longlistselector-on-wp