Tuesday, 15 February 2011

wpf - CheckBoxes In ListBox Make Scrolling Lag -


I am working on a small view in WPF with some buttons and The list box whose items contain a template containing a checkbox and a ContentPresenter . When I start scrolling in ListBox then the ScrollBar runs up and down below, it's like a display and I think this checkbox Is due to. I think the checkbox is a random rendering animation that takes a few microseconds to fade into the tick and moves on those sinks, so the lag appears.

I may be wrong and maybe this is something else due to this problem. Fathermore as soon as a sidenote because it matters to you that people are running Windows 7 on Intel i5.

When I leave the check box it runs very beautiful away from the template.

What do you guys suggest me to do?

I do not know how to disable animation and I do not want that kind of behavior.

Edit: I have 5000 items in the list box

Here's my XML:

  & lt; ListBox ItemsSource = "{Binding Source}" & gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; StackPanel Orientation = "Horizontal" & gt; & Lt; Check Box IsChecked = "{Check Binding}" /> & Lt; ContentPresenter Content = "{binding text}" /> & Lt; / StackPanel & gt; & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt;   

This is my view modal:

  see public categoryModel {public view model () {this.Source = new ObservableCollection & lt; ListItem & gt; (); For (Int i = 0; I <5000; i ++) {this.Source.Add (new list item) (text = "test" + I, check = true}); }} Edit public supervision & lt; ListItem & gt; Source {get; Set; }} Public class ListItem {public bool checked {get; Set; } Public string text {get; Set; }}   

This is my main window:

  public partial square main window: window {public main window ()} {InitializeComponent (); this. Datacentext = new view modal (); Try to use  Virtualization StackPanel.VirtualizationMode = "Recycling"  To improve performance during scrolling, try to use  ScrollViewer.IsDeferredScrollingEnabled = "True"  for suspended scrolling in extreme positions. For more information see:  

Note: You can try to run this code under other operating systems such as: Windows XP < / Em> I have thought that Windows 7 Optimization was implemented differently in comparison to XP on WPF rendering. Since some code normally goes to XP, but by seven breaks (but maybe I am wrong).

PS I found the best - "Improve scrolling performance in WPF." Author: Cedric Dissal. This can be useful.

No comments:

Post a Comment