I am sure this is something only my newb-ness can create, but, as seen in the screenshot, the border specified in the code snippet renders slightly indented from the left:
Here is the code for the data template:
<DataTemplate x:Key="itemsTemplate">
<Border BorderThickness="1,0,0,1" BorderBrush="Black" >
<TextBlock Text="{Binding DisplayString}" TextWrapping="Wrap" Cursor="Hand" FontFamily="Tahoma" />
&开发者_C百科lt;/Border>
</DataTemplate>
I added the border on the left to better illustrate the problem. What I really want is the bottom border to extend the full width of the ListboxItem. Why is it indented? How do I fix this?
Thanks!
In addition to DataTemplate you should declare this Style:
<Style TargetType="ListBoxItem">
<Setter Property="Padding"
Value="0"/>
</Style>
my guess is that it is the ListBox that is doing that--setting a margin on the container for the listbox item. probably you are going to have to set a margin on your border that is like, -5 (or so) to get it back over where you want it.
something like this:
<Border margin="-5,0,0,0">.....</Border>
should fix it
精彩评论