Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6369141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:45:54+00:00 2026-05-25T00:45:54+00:00

I have a Listbox displaying data, with a small border separating each item. The

  • 0

I have a Listbox displaying data, with a small border separating each item. The problem is that I only want a border between items, not at the top or bottom of the list. I figured that if I can retreive the first ListBoxItem in the list I can set it’s border’s thickness to 0.0, meaning that the borders only appear inbetween list items.

<ListBox Name="PerformanceList" ItemsSource="{Binding JFifoCollection}" HorizontalContentAlignment="Stretch">
                        <ListBox.ContextMenu>
                            <ContextMenu>
                                <MenuItem Name="ClearPerf" Click="MenuItem_Click" Header="Clear" />
                            </ContextMenu>
                        </ListBox.ContextMenu>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Border BorderThickness="0,1,0,0" BorderBrush="#ff000099">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="100" />
                                            <ColumnDefinition Width="100" />
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition />
                                        </Grid.RowDefinitions>
                                        <TextBlock Text="{Binding Path=tid}" Grid.Column="0" Grid.RowSpan="6" FontSize="65pt" VerticalAlignment="Center" />
                                        <TextBlock Grid.Column="1" Grid.Row="0" FontWeight="Bold">hwcrc</TextBlock>
                                        <TextBlock Text="{Binding Path=HWCRC}" Grid.Column="2" Grid.Row="0" />
                                        <TextBlock Grid.Column="1" Grid.Row="1" FontWeight="Bold">frame count</TextBlock>
                                        <TextBlock Text="{Binding Path=Frames}" Grid.Column="2" Grid.Row="1" />
                                        <TextBlock Grid.Column="1" Grid.Row="2" FontWeight="Bold">fps</TextBlock>
                                        <TextBlock Text="{Binding Path=FPS}" Grid.Column="2" Grid.Row="2" />
                                        <TextBlock Grid.Column="1" Grid.Row="3" FontWeight="Bold">faults</TextBlock>
                                        <TextBlock Text="{Binding Path=Faults}" Grid.Column="2" Grid.Row="3" />
                                        <TextBlock Grid.Column="1" Grid.Row="4" FontWeight="Bold">info</TextBlock>
                                        <TextBlock Text="{Binding Path=Info}" Grid.Column="2" Grid.Row="4" />
                                        <TextBlock Grid.Column="1" Grid.Row="5" FontWeight="Bold">config</TextBlock>
                                        <TextBlock Text="{Binding Path=Config}" Grid.Column="2" Grid.Row="5" />
                                    </Grid>
                                </Border>
                                <DataTemplate.Triggers>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

Is it possible to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:45:55+00:00Added an answer on May 25, 2026 at 12:45 am

    Two ways to do this:

    One is to implement a boolean IsFirstItem property in the view model that’s set to true when an item is the first item in whatever collection contains it. (This assumes that an item can only be contained by one collection, and that items have access to their containing collection, which are not always the case.) Then add a style to the Border:

    <Style TargetType="Border">
       <Setter Property="BorderThickness" Value="0,1,0,0"/>
       <Style.Triggers>
          <DataTrigger Binding="{Binding IsFirstItem}" Value="True">
             <Setter Property="BorderThickness" Value="0"/>
          </DataTrigger>
       </Style.Triggers>
    </Style>
    

    Another is to create a placeholder object and add it to the end (or the beginning) of the collection. Then use template selection to render it with a different template from the normal items, e.g.:

    <ListBox.Resources>
       <DataTemplate TargetType="{x:Type MyRealItem}">
          <!-- what most items should look like -->
       </DataTemplate>
       <DataTemplate TargetType="{x:Type MyPlaceholderItem}">
          <!-- what the placeholder item should look like -->
       </DataTemplate>
    </ListBox.Resources>
    <ListBox.ItemTemplate>
       <DataTemplate>
          <ContentPresenter Content="{Binding}"/>
       </DataTemplate>
    </ListBox.ItemTemplate>
    

    If it’s at the end, for instance, you can then give the placeholder a negative top margin that’s the same width as your border thickness – so basically you’re drawing a rectangle of the background color on top of the bottom border of the last item in your list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a databound listbox which is actually displaying two columns of data. It
I have a ListBox displaying some items, and in certain modes I stamp a
I have a ListBox which displays items of variable height. I want to show
I have a ListBox that when in focus, and when I have an item
i have a listbox and i would want to display a label displaying: scrolling
I have a ListBox that contains a number of User items that are DataTemplate
I have a listbox that should display data that contains 2 fields: time and
I have a ListBox displaying items with a template something like this: <ListBox x:Name=CustomerResultList
I´m displaying images in a ListBox and i want to control the size (small,
I have a ListBox that has a style defined for ListBoxItems. Inside this style,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.