Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not really sure why this happens, but I can tell you how to make it work.</p> <p>It looks like you are never telling the DataGrid that the items in EntryCollection have changed, by raising an appropriate event. </p> <p>The <code>OnPropertyChanged("EntryCollection")</code> call you have in the <code>Test</code> method has no effect, since you have <code>Mode=OneTime</code> on the DataGrid binding, and since the <code>EntryCollection</code> object is a <code>List</code>and not a <code>ObservableCollection</code>, the adding of items to it is not raising any events to notify the DataGrid.</p> <p>The way I see it, you can do two things to fix this.</p> <ol> <li><p>Make <code>EntryCollection</code> an <code>ObservableCollection</code> so the DataGrid is notified as items are added/removed. Then you can remove the <code>OnPropertyChanged</code> call, and still have <code>Mode=OneTime</code>.</p> <pre><code>public Viewer() { EntryCollection = new ObservableCollection&lt;Entry&gt;(); InitializeComponent(); Container.DataContext = this; } public ObservableCollection&lt;Entry&gt; EntryCollection { get; set; } internal void Test() { for (int i = 0; i &lt; 200000; i++) { Entry entry = new Entry() { ErrorCode = 0, Time = DateTime.Now.ToString(), Content = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." }; EntryCollection.Add(entry); } } </code></pre></li> <li><p>Instead of adding items to <code>EntryCollection</code>, set it to a new instance and raise the <code>PropertyChanged</code> event. Doing it that way, you need to remove the <code>Mode=OneTime</code> setting in the XAML.</p> <pre><code>public Viewer() { EntryCollection = new List&lt;Entry&gt;(); InitializeComponent(); Container.DataContext = this; } public List&lt;Entry&gt; EntryCollection { get; set; } internal void Test() { List&lt;Entry&gt; test = new List&lt;Entry&gt;(); for (int i = 0; i &lt; 200000; i++) { Entry entry = new Entry() { ErrorCode = 0, Time = DateTime.Now.ToString(), Content = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." }; test.Add(entry); } EntryCollection = test; OnPropertyChanged("EntryCollection"); } </code></pre></li> </ol>
 

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