Using SwipePanel in ListBox


screen-2.png

ListBox is supported sorting by defining ItemsPanel as SwipePanel.
Also, ListBox should handled attached event s:SwipePanel.Moving

XAML:

<ListBox Grid.Column="1" s:SwipePanel.Moving="MovingS">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <s:SwipePanel></s:SwipePanel>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBoxItem>123</ListBoxItem>
    <ListBoxItem>12345</ListBoxItem>
    <ListBoxItem>1234567</ListBoxItem>
    <ListBoxItem>123456789</ListBoxItem>
    <ListBoxItem>123456789AB</ListBoxItem>
</ListBox>


C# code:

  private void MovingS(object sender, MovingEventArgs e)
  {
        var tabCtrl = sender as ListBox;
        if (tabCtrl != null)
        {
            var t = tabCtrl.Items[e.OldIndex];
            tabCtrl.Items.RemoveAt(e.OldIndex);

            tabCtrl.Items.Insert(e.NewIndex, t);
        }
  }

Last edited Jan 8, 2012 at 12:31 PM by safopet, version 3

Comments

No comments yet.