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

  • Home
  • SEARCH
  • 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 781831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:17:34+00:00 2026-05-14T20:17:34+00:00

I want to have a border around ListViewItem (row in my case). ListView source

  • 0

I want to have a border around ListViewItem (row in my case). ListView source and columns generated during Runtime. In XAML i have this structure:

<ListView Name="listViewRaw">
   <ListView.View>
      <GridView>
      </GridView>
   </ListView.View>
</ListView>

During Runtime i bind listview to DataTable, adding necessary columns and bindings:

        var view = (listView.View as GridView);
        view.Columns.Clear();   
        for (int i = 0; i < table.Columns.Count; i++)
        {
            GridViewColumn col = new GridViewColumn();
            col.Header = table.Columns[i].ColumnName;
            col.DisplayMemberBinding = new Binding(string.Format("[{0}]", i.ToString()));
            view.Columns.Add(col);
        }

        listView.CoerceValue(ListView.ItemsSourceProperty);

        listView.DataContext = table;
        listView.SetBinding(ListView.ItemsSourceProperty, new Binding());

So i want to add border around each row, and set border behavior (color etc) with DataTriggers (for example if value in 1st column = “Visible”, set border color to black).
Can i put border through DataTemplate in ItemTemplate? I know solution, where you manipulate with CellTemplates, but i don’t really like it. I want something like this if this even possible.

<DataTemplate>
   <Border Name="Border" BorderBrush="Transparent" BorderThickness="2">
      <ListViewItemRow><!-- Put my row here, but i ll know about table structure only during runtime --></ListViewItemRow>
   </Border>
</DataTemplate>
  • 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-14T20:17:35+00:00Added an answer on May 14, 2026 at 8:17 pm

    You’ll have to set your border in the ControlTemplate

    <Style x:Key="BorderedItem" TargetType="ListViewItem">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="ListViewItem">
            <Border Name="Border" BorderBrush="Transparent" BorderThickness="2">
              <ContentPresenter />
            </Border>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
    

    Now you can set this style in your ListView

    <ListView ItemContainerStyle="{StaticResource BorderedItem}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, this is driving me crazy right now. I want to have a border
I have a listview with a DataTemplate that has a ComboBox. I want the
I want to have a game where the view will move around as the
In other browsers except IE7 and lower the hr displays a border around the
I am trying to figure out how to add a border only inside the
I have a Window that has two primary areas. One is a TextBox inside
I have an interface with some <a> tags, at the end is a div
i would like to have an event fired in jquery, if the validators of
When a user clicks my Validate Button ( in my C#, WinForm, .net 3.5

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.