wpf - How to stop DataGrid from flickering when using ObservableCollection? -
I am struggling with This is setup and requirements 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 I have so many issues with it, in which there are problems updating the archive on the background thread and most recent 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 See the modal code for the binding I used 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 WPF and for the
ObsavableCollection I have some time and now I need some help.
ObservableCollection
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.
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>
& 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;
// 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; }
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
Post a Comment