locked
FluidMoveBehavior with sortable ListBox RRS feed

  • Question

  • Hi I have a ListBox setup with the following behavior.

    The user can sort the items of the listbox as desired, but if I rebuild the ObservableCollection from scratch in the right order, then the fluid movement is lost because brand new UIElements are created. Is there a way to get around this ?

    In WPF the ObservableCollection class has a Move method, but I can find a way in Silverlight of doing in place sorting.

            <ListBox.ItemsPanel>
              <ItemsPanelTemplate>
                <StackPanel>
                  <i:Interaction.Behaviors>
                    <ei:FluidMoveBehavior AppliesTo="Children" Duration="0:0:0.5">
                      <ei:FluidMoveBehavior.EaseY>
                        <CubicEase EasingMode="EaseInOut" />
                      </ei:FluidMoveBehavior.EaseY>
                      <ei:FluidMoveBehavior.EaseX>
                        <CubicEase EasingMode="EaseInOut" />
                      </ei:FluidMoveBehavior.EaseX>
                    </ei:FluidMoveBehavior>
                  </i:Interaction.Behaviors>
                </StackPanel>
              </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
    

     

    Tuesday, March 29, 2011 11:01 AM

All replies

  • Hello Clement,

    a while ago I wrote a short article about how to Sort an ObservableCollection(Of T) in Silverlight 3. Maybe this might help. Let me know if not.

    Best regards,

    Martin

    Tuesday, March 29, 2011 2:10 PM
  • Martin, the issue is not to be able to actually sort the collection.

    The issue is how to make it play nice with the FluidMoveBehavior. It requires in place sorting rather than removing and re-adding items as you do in your example.

    Wednesday, March 30, 2011 3:44 AM