wpf - How to stop DataGrid from flickering when using ObservableCollection? -


I am struggling with WPF and for the ObsavableCollection I have some time and now I need some help.

This is setup and requirements

  • Using MongoDB as a backing database
  • Loads of heavy data in the database Amount to be saved
  • The UI should be able to display logs as they are inserted in the database (real time-iIS)
  • UI Data Grid ObservableCollection
  • Due to memory usage, the UI should be grid and paget and can have millions of records
  • view logs On Ane, if the new entry is created and displayed, should be removed; This is due to paging and a set page size (50 log entries will be shown only at one time)
  • A new log entry is created when using ActiveMQ to indicate

    Therefore, it is essentially a rolling log view where an entry comes up and an entry gets out. I should keep selected items and show updates in real time (this is why I am using ObsavableCollection ). Logs can be filtered and pages can be navigated, so I thought there are new log entries and it would be easier to bring the whole page while displaying it; This will allow me to get the entries that have already been missed.

    I have so many issues with it, in which there are problems updating the archive on the background thread and most recent Datagreat "playful" when a new entry was created I am thinking that due to the refreshment of the entire collection every time it is fickle, but the option (manually adding and removing items) is very complex and due to the complexities of filtering and paging that path I do not like to go / P>

    Is there a good pattern or suggestion to stop this "flickering" or is there a better way to apply filterable log footage to update in real time?

    Xaml & lt; DataGrid ItemsSource = "{Binding Entries, ISASIN = True}" Autocontent Columns = "False" israel Online = "True" Canusersort Column = "Fail" Enabled Column Virtualization = "True" Virtualization = "True" VirtualizingPanel.IsVirtualizing = "True" VirtualizingPanel.VirtualizationMode = "Recycling" & gt; & Lt; DataGrid.Columns & gt; & Lt; DataGridTextColumn Header = "Timestamp" Binding = "{Binding Timestamp}" /> & Lt; DataGridTextColumn header = "from" binding = "{message binding}" /> & Lt; DataGridTextColumn Header = "To" binding = "{Binding MessageTo}" /> & Lt; DataGridTextColumn header = "type" binding = "{binding message type}" /> & Lt; /DataGrid.Columns> & Lt; / Data grid & gt;

    See the modal code for the binding I used

      // option 1 public view () {this.Entries = new ObservableCollection & lt; Model & gt; (); } Public Zero UpdateData () {this.Entries.Clear (); Forchach (model m in fatecodles (model)) Entry Add (M); } Public transit collection & lt; Model & gt; {Receive entries; Private set; } // Option 2 Private List & lt; Model & gt; M_Entries = New list & lt; Model & gt; (); Public Zero UpdateData () {this.m_Entries.Clear (); This.m_Entries.AddRange (FetchModels ()); This.NotifyPropertyChanged ((= = gt; it..in); } Public transit collection & lt; Model & gt; Entries {Back New Observable Collection & Lt; Model & gt; (This.M_Enterridge); }} // Option 3 Public ViewDeload () {this.Incent = New Observational Collection & lt; Model & gt; (); } Public Zero UpdateData () {var tmp = this.Entries; this. Entrees = null; Tmp.Clear (); Model m in the fetchModels (model) tmp.Add (m); this. Entries = TMP; This.NotifyPropertyChanged ((= = gt; it..in); } Public transit collection & lt; Model & gt; {Receive entries; Private set; }   

    As soon as I miss more things, I post it.

    This is what came with me and works very well, although I do not like it and It seems that I can bow to the suggestions of Lee O in the above comments; But for this time because time limits are coming here i did what i did UpdateData has its own thread

      Public Zero UpdateData () {var items = this.m_Cache.All & lt; Model & gt; (). OrderByDescending (x => x.Timestamp) .Take (50) .Skip (0) .ToList (); Lock (this.m_Sync) {var toRove = this.Entries.Except (item) .toList (); Var toAdd = items.Except (this.Entries) .toList (); Foreach (toAdd in Model) this. Entry Add (M); Foreach (toremove in model meter) Entry Remove (M); } This.NotifyOfPropertyChange ((= = & gt; all of these vacancies);}    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -