2014-02-27 28 views
1

我正在爲Windows Phone 7構建一個應用程序,其中我在列表框中顯示一些數據。我想在每個項目之後添加一個圖像以區別於另一個。我的xaml代碼是:如何在列表框中的每個項目之後放置一條水平線

<ListBox Name="listBox1" BorderThickness="0" Height="679" VerticalAlignment="Bottom" Margin="12,0,0,-29" Background="White" Grid.Row="1"> 
<ListBox.ItemTemplate> 
<DataTemplate> 
<ScrollViewer HorizontalScrollBarVisibility="Disabled" Height="80" Width="400"> 
<StackPanel Orientation="Horizontal" Margin="0,0,0,0" Background="White" Width="500"> 
<Image Source="{Binding ImageBind }" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Margin="0,0,20,10" Height="100" Width="145" /> 
<StackPanel Orientation="Vertical"> 
     <StackPanel Orientation="Horizontal"> 
    <TextBlock Text="{Binding city_name}" Foreground="Red" FontFamily="Verdana" /> 
    <TextBlock Text=", " Foreground="Red" FontFamily="Verdana" /> 
    <TextBlock Text="{Binding state}" Foreground="Red" FontFamily="Verdana" /> 
     </StackPanel> 
    <TextBlock Text="{Binding Path=city_description}" TextWrapping="Wrap" Foreground="Black" FontFamily="Verdana"></TextBlock> 
    <Image Source="Image/index.jpg"/> 
     </StackPanel> 
    </StackPanel> 
    </ScrollViewer> 
    </DataTemplate> 
     </ListBox.ItemTemplate> 
    </ListBox> 

index.jpg圖像是我想添加的水平線。請幫助在哪裏添加圖像,使我得到的圖像爲每個數據

+0

似乎有待解決前面 Amr

回答

1

選中此分隔符:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/e09926c2-5d53-4337-ba76-d1c786ec9ced/listbox-with-horizontal-lineseparator?forum=wpf

1回答

嘗試是這樣的:

<ListBox Name="listBox1" BorderThickness="0" Height="679" VerticalAlignment="Bottom" Margin="12,0,0,-29" Background="White" Grid.Row="1"> 
<ListBox.ItemTemplate> 
<DataTemplate> 
<ScrollViewer HorizontalScrollBarVisibility="Disabled" Height="80" Width="400"> 
<StackPanel Orientation="Horizontal" Margin="0,0,0,0" Background="White" Width="500"> 
<Image Source="{Binding ImageBind }" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Margin="0,0,20,10" Height="100" Width="145" /> 
<StackPanel Orientation="Vertical"> 
     <StackPanel Orientation="Horizontal"> 
    <TextBlock Text="{Binding city_name}" Foreground="Red" FontFamily="Verdana" /> 
<Separator Width="{Binding ElementName=listBox1, Path=ActualWidth}"/> 
    <TextBlock Text=", " Foreground="Red" FontFamily="Verdana" /> 
<Separator Width="{Binding ElementName=listBox1, Path=ActualWidth}"/> 
    <TextBlock Text="{Binding state}" Foreground="Red" FontFamily="Verdana" /> 
<Separator Width="{Binding ElementName=listBox1, Path=ActualWidth}"/> 
     </StackPanel> 
    <TextBlock Text="{Binding Path=city_description}" TextWrapping="Wrap" Foreground="Black" FontFamily="Verdana"></TextBlock> 
<Separator Width="{Binding ElementName=listBox1, Path=ActualWidth}"/> 
    <Image Source="Image/index.jpg"/> 
     </StackPanel> 
    </StackPanel> 
    </ScrollViewer> 
    </DataTemplate> 
     </ListBox.ItemTemplate> 
    </ListBox> 

這會幫助你;)

+0

我無法做到這一點。你可以編輯它在我寫的代碼爲了得到分隔符 – bhaku

+0

我將編輯我的評論 –

+0

嘿frnd我收到一個錯誤,找不到類型分隔符。我正在爲Windows Phone應用程序構建它。我需要在這種情況下添加一些參考 – bhaku

相關問題