Note that there are some explanatory texts on larger screens.

plurals
  1. POListView ItemTemplate and ItemsSource don't show expected value
    text
    copied!<p><br> I got a Problem with the following code:</p> <pre><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)); } } </code></pre> <p>The Code of the FileStatus object is:</p> <pre><code>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> <p>The XAML of the ListView is:</p> <pre><code>&lt;ListView Name="lb_data" Grid.Row="2" DataContext="{Binding}" ItemTemplate="{StaticResource fileStatusTemp}"&gt; &lt;/ListView&gt; </code></pre> <p>The XAML of fileStatusTemp:</p> <pre><code>&lt;DataTemplate x:Key="fileStatusTemp"&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Path=filename}" &gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; </code></pre> <p>The ItemSource-property is set in the constructor of the window:</p> <pre><code>lb_data.ItemSource = files; </code></pre> <p>Thanks to KDiTraglia, for the advice :)<br> 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...<br> I hope you can help me :)<br> Greetings Knerd</p>
 

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