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 9236531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:18:54+00:00 2026-06-18T07:18:54+00:00

I am developing wpf application, in which i have listview control. I am very

  • 0

I am developing wpf application, in which i have listview control. I am very new to wpf. But managed to add some styles and display horizontal gridlines inside Listview as below,

 <DataTemplate x:Key="IDBorderedCellTemplate">

                <Border BorderBrush="Black" Margin="0,5,0,1"

                BorderThickness="0,0,0,1" >

                    <TextBlock Foreground="MediumBlue" FontFamily="Calibri" Margin="3,0,0,2" Text=""
                />

                </Border>
            </DataTemplate>


 <ListView.View>

                <GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle}">

                    <!-- Product ID -->

                    <GridViewColumn



          CellTemplate="{StaticResource IDBorderedCellTemplate}">

Now my problem is i am uable to display items in listview when window is loaded, which is displaying only gridlines. As my requirement is i have a browse button which i browse files, these browsed files must be displayed in listview.

As in load event i am adding following lines of code,

    try
    {

        listviewitem = new ListViewItem();
        //displays only the filename in the listview
        listviewitem.Content = System.IO.Path.GetFileName(_name);
        _listFiles.Items.Add(listviewitem);
    }
    catch (Exception)
    {
   }

This data is not displaying in listview after adding the gridview settings in xaml. Now its displays only gridlines.
Any suggesions/help is appreciable.

Regards
Ravi

  • 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-06-18T07:18:55+00:00Added an answer on June 18, 2026 at 7:18 am

    Choose the ItemsSource of listview as ObservableCollection or BindingList
    for dynamic/frequently changing data instead of using listviewItem.

    XAML

      <ListView  Name="listView1" ItemsSource="{Binding FileStore}">
        <ListView.View>
            <GridView>
                <GridViewColumn Width="120" Header="Files" DisplayMemberBinding="{Binding}" />
            </GridView>
        </ListView.View>
     </ListView>
    

    C#

     public partial class MainWindow : Window
     {
       public ObservableCollection<string> fileList= new ObservableCollection<string>();
    
        public MainWindow()
        {
           InitializeComponent();
            this.DataContext = this;
           // Add files to fileList (ObservableCollection)  
        }
    
        public ObservableCollection<string> FileStore
       {
          get { return fileList; }
       } 
      }
    

    Can add items to ObservableCollection anywhere like browse button click or load.

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

Sidebar

Related Questions

I am developing an application in C# WPF which will have Client-Server architecture (Client
I am developing wpf application in C#. I have one button on which I
I have an application which I am developing using WPF\Prism\MVVM. All is going well
I am developing a WPF application, and have a TextBlock which I want to
I am currently developing a new WPF application and have the majority of my
We are developing a WPF Application which should support multiple Languages. Since we have
I have a WPF Browser Application consisting mostly of wpf pages which I'm developing
I'm developing a WPF application using MVVM. Inside a Window, I have a control
After developing a WPF application without Source Control, I decided to add the solution
Context: I'm developing a WPF application which will contain a lot of different screens.

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.