0

Here is the XAML code for the ListView.

<ListView VerticalAlignment="Stretch"
          HorizontalAlignment="Stretch"
          x:Name="listView1">
    <ListView.ItemTemplate>
        <DataTemplate>
            <Border HorizontalAlignment="Stretch"
                    BorderThickness="1"
                    BorderBrush="LightBlue">
                <StackPanel Orientation="Vertical">
                    <Label BorderThickness="0,0,0,1"
                           BorderBrush="#BABABA"
                           HorizontalAlignment="Stretch">Keywords</Label>
                    <TextBlock Text="{Binding keywords}"
                               Foreground="#3399AA"
                               HorizontalAlignment="Stretch" />
                    <Label BorderThickness="0,0,0,1"
                           BorderBrush="#BABABA">Content</Label>
                    <TextBlock MaxHeight="50"
                               Text="{Binding contentAsString}"
                               TextWrapping="Wrap"
                               Foreground="Black"
                               Height="auto"
                               Width="auto" />
                </StackPanel>
            </Border>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

And here is how it looks

...

No matter what I've tried I couldn't create a border for the whole listview item. How can we do that?

Ugur
  • 1,257
  • 2
  • 20
  • 30
ozgur
  • 2,549
  • 4
  • 25
  • 40
  • 2
    Do you want to [stretch](http://stackoverflow.com/q/3715781/1997232) ListViewItem? Btw, the bitmap button looks ugly, you should use vector graphics (Pathes, etc) in wpf instead. – Sinatr Oct 07 '15 at 09:27
  • Do you want the Complete ListView to be in a Border or Just a ListViewItem – Mohit S Oct 07 '15 at 09:28
  • @Sinatr I agree with the button thing. It is just a temporary thing. Your link solved my problem. I didn't know that I can give a style to listview item this way. Now everything is fine. – ozgur Oct 07 '15 at 09:32
  • @MohitShrivastava just the listview. But solved the problem. – ozgur Oct 07 '15 at 09:33

1 Answers1

2

Try with Stretch

  <ListView>
      <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
          <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        </Style>
      </ListView.ItemContainerStyle>
    </ListView>

. . .

<Viewbox Stretch="Fill"/>
Ugur
  • 1,257
  • 2
  • 20
  • 30