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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:16:04+00:00 2026-06-03T14:16:04+00:00

I got a Problem with the following code: FolderBrowserDialog ofd = new FolderBrowserDialog(); ofd.Description

  • 0

I got a Problem with the following code:

FolderBrowserDialog ofd = new FolderBrowserDialog();
        ofd.Description = "Wählen Sie bitte den Ordner mit den Videodateien die Sie verschieben und umbenennen wollen...";
        if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
            string path = ofd.SelectedPath;
            foreach (var file in Directory.GetFiles(path)) {
                files.Add(new FileStatus(file, new FileInfo(file).Length));
            }
        }

The Code of the FileStatus object is:

public FileStatus(string filename, long filesize, long currentsize = 0) {
        this.currentsize = currentsize;
        this.filename = filename;
        this.filesize = filesize;
    }
    public string filename { get; set; }
    public long filesize { get; set; }
    public long currentsize { get; set; }
    public double percent {
        get {
            return (currentsize / filesize) * 100;
        }
    }

The XAML of the ListView is:

<ListView Name="lb_data" Grid.Row="2" DataContext="{Binding}" ItemTemplate="{StaticResource fileStatusTemp}">
    </ListView>

The XAML of fileStatusTemp:

<DataTemplate x:Key="fileStatusTemp">
        <StackPanel>
            <TextBlock Text="{Binding Path=filename}" ></TextBlock>
        </StackPanel>
</DataTemplate>

The ItemSource-property is set in the constructor of the window:

lb_data.ItemSource = files;

Thanks to KDiTraglia, for the advice 🙂
So the Problem is that when I run this code it doesn’t displays the filename. It just shows nothing.
In another project a similiar piece of code works…
I hope you can help me 🙂
Greetings Knerd

  • 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-03T14:16:05+00:00Added an answer on June 3, 2026 at 2:16 pm

    You are missing an itemssource=”{binding ??}” in your list view. I am also skeptical as to whether this line is working as you intend…

    DataContext="{Binding}"
    

    Edit:

    I copied this all into a test project and it works fine, here’s my entire project verbatim, maybe I did something small.

    dowhilefor makes a good point about INotifyPropertyChanged, my code works on load, but would not work if the files were added from an event other than the constructor. To fix this easily, just change List to ObservableCollection (don’t forget to include ‘using System.Collections.ObjectModel’). I updated my code below.

    public partial class MainWindow : Window
    {
        public ObservableCollection<FileStatus> files { get; set; }
        public MainWindow()
        {
            InitializeComponent();
            files = new ObservableCollection<FileStatus>();
            lb_data.ItemsSource = files;
    
            FolderBrowserDialog ofd = new FolderBrowserDialog();
            ofd.Description = "Wählen Sie bitte den Ordner mit den Videodateien die Sie verschieben und umbenennen wollen...";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string path = ofd.SelectedPath;
                foreach (var file in Directory.GetFiles(path))
                {
                    files.Add(new FileStatus(file, new FileInfo(file).Length));
                }
            }
        }
    }
    

    –

    <Window x:Class="WPFtest5.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <DataTemplate x:Key="fileStatusTemp">
                <StackPanel>
                    <TextBlock Text="{Binding Path=filename}" />
                </StackPanel>
            </DataTemplate>
        </Window.Resources>
        <ListView Name="lb_data" ItemTemplate="{StaticResource fileStatusTemp}"/>
    </Window>
    

    –

    public class FileStatus
    {
        public FileStatus(string filename, long filesize, long currentsize = 0)
        {
            this.currentsize = currentsize;
            this.filename = filename;
            this.filesize = filesize;
        }
        public string filename { get; set; }
        public long filesize { get; set; }
        public long currentsize { get; set; }
        public double percent
        {
            get
            {
                return (currentsize / filesize) * 100;
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got a problem with the following code: File folder = new File(Environment.getExternalStorageDirectory() +
I have the following code, but i got a problem. Within my While, a
I got a little problem. Sometimes, when I try to call the following code,
My Problem is the following. I got this code and i guess a corrupt
I've got a problem with the following code pasted below, the problem seems to
I got a problem when I tried to find some characters with following code:
I got an interesting time-travel problem today, using the following code: for (int i
i have got the following problem: I want to create a new Liferay Theme
i've got the following Problem / Question: I have HTML Code like this: <div
I've got a problem with following example code in flex: Test.mxml: <?xml version=1.0 encoding=utf-8?>

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.