Separator Between Items in LongListSelector on WP

[亡魂溺海] 提交于 2020-01-21 23:23:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!