New 3.5 SP1 features: ScrollViewer.IsDeferredScrollingEnabled; AlternationCount;IEditableCollectionView

3 more features which go hand in hand are the:

· ScrollViewer.IsDeferredScrollingEnabled

· AlternationCount

· IEditableCollectionView

All the above have been used in a sample which looks like this - it supports add/delete/cancel (escape key) operations

ScrollViewer.IsDeferredScrollingEnabled

This is an opt in features which provides a perceived performance improvement. What it does is that content doesn’t scroll while the scrollbar is in action. Once you stop the content refreshes to the new scrolled value. In this case you avoid the possible jitter motion in scrolling.

Usage: <ListBox ScrollViewer.IsDeferredScrollingEnabled="true”>

Alternation Count

This allows setting alternating properties on rows of an items Control. A lot of our customers have been writing the alternating color of listboxes, listviews,… Now it’s a few lines code which gives you this functionality J

Usage: <Style.Triggers>

<Trigger Property="ItemsControl.AlternationIndex" Value="0">

<Setter Property="Background" Value="LightBlue"></Setter>

</Trigger>

<Trigger Property="ItemsControl.AlternationIndex" Value="1">

<Setter Property="Background" Value="Maroon"></Setter>

<Setter Property="Foreground" Value="White"></Setter>

</Trigger>

</Style.Triggers>

<ListBox AlternationCount="2">

IeditableCollectionView

Now with this feature you can easily add/remove/edit items in a collection. Do I hear some shouts of joy

The first step is to implement the IEditableObject interface. This requires implementing

· BeginEdit à store the current value in a temp variable/object

· CancelEdit à Restore the temp value into the current object

· EndEdit à clear the temp value

That’s it for your data changes. Now for the operations itself. First you get hold of the IEditiableCollectionView since it exposes the operations.

(IEditableCollectionView)(CollectionViewSource.GetDefaultView(itemsList.Items));

This class exposes the following functions

iecv.AddNew();

iecv.EditItem();

iecv.CommitNew();

iecv.CommitEdit();

iecv.CancelNew();

iecv.CancelEdit();

The code is attached. Have fun.

Share this post

 

ScrollViewerFunctionalities.zip