Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are missing an itemssource="{binding ??}" in your list view. I am also skeptical as to whether this line is working as you intend...</p> <pre><code>DataContext="{Binding}" </code></pre> <p>Edit:</p> <p>I copied this all into a test project and it works fine, here's my entire project verbatim, maybe I did something small.</p> <p>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.</p> <pre><code>public partial class MainWindow : Window { public ObservableCollection&lt;FileStatus&gt; files { get; set; } public MainWindow() { InitializeComponent(); files = new ObservableCollection&lt;FileStatus&gt;(); 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)); } } } } </code></pre> <p>-</p> <pre><code>&lt;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"&gt; &lt;Window.Resources&gt; &lt;DataTemplate x:Key="fileStatusTemp"&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Path=filename}" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/Window.Resources&gt; &lt;ListView Name="lb_data" ItemTemplate="{StaticResource fileStatusTemp}"/&gt; &lt;/Window&gt; </code></pre> <p>-</p> <pre><code>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; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload