This is a migrated thread and some comments may be shown as answers.

Disable animation after removing the item

3 Answers 49 Views
SlideView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vitalii
Top achievements
Rank 2
Vitalii asked on 18 May 2014, 02:53 AM
I have a SlideView with items that can be removed. After item is removed, SlideView is automatically jumps to the first item, though i'd like it to jump to the next one.

I tried (i'm using mvvm, so ItemsList is a binded list and ProceedToNextItemEvent is an event my view is subscribed to and calls MySlide.MoveToNextItem())

            ProceedToNextItemEvent(this, null);
            ItemsList.Remove(currentItem);

But this also triggers jumping to 1 element. Can i disable it?

3 Answers, 1 is accepted

Sort by
0
Vitalii
Top achievements
Rank 2
answered on 18 May 2014, 02:20 PM
Well, i managed to make a workaround, but i dont like it much... In VM, i'm storing current item and firing ProceedToNextItemEvent.

In the View, i subscribed to OnSlideAnimationCompleted() and calling VM's CommitItemsRemovement. Inside 

public void CommitItemsRemovement()
        {
            if (itemToRemove != null)
            {
                if (PreItemRemoveEvent != null) PreItemRemoveEvent(this, null);

                ItemsList.Remove(itemToRemove);
                itemToRemove = null;

                if (PostItemRemoveEvent != null) PostItemRemoveEvent(this, null);
            }
     }

and in the view again

private object currentItem;
        private void PreItemRemoveEvent(object _sender, EventArgs _eventArgs)
        {
            currentItem = ProductsSlide.SelectedItem;
        }
        private void PostItemRemoveEvent(object _sender, EventArgs _eventArgs)
        {
            if (currentItem != null)
                ProductsSlide.SelectedItem = currentItem;
        }

So, after i pressed "remove" button, i'm saving current item, playing animation, after animation is done i'm checking if saved item is exists, and if yes, i'm saving new current item (where view just navigated to), remove previous item and set current item as SelectedItem. It kinda works, but i'd prefer just to have a property OnItemRemoveJumpToTheFirstItem = false;



















0
Vitalii
Top achievements
Rank 2
answered on 18 May 2014, 04:30 PM
Well, i managed to simplify it by binding SelectedItem to a property, but still it is looking a bit complicated:
tap (on Remove button) -> animatie to the next item -> animation ends -> save current -> remove previous item (now it should start jumping to 0 item) -> restore current
0
Todor
Telerik team
answered on 21 May 2014, 11:10 AM
Hello Vitalii,

Thank you for writing.

The complexity of the approach seems to be related to the desired experience. The steps from your last post seem to be the shortest way to achieve the current experience. For example if you don't want to animate to the next item, but instead just "jump to it" when the selected item is removed, you can simply change your selected item property to the next item. Then the steps would be:

Tap (on Remove button) -> save the currently selected item -> change the selected item property to the next item from your collection -> remove the stored previously selected item.

If you want the animation to play, there is no other way but the one you are currently using: force animation, wait for its finish and then perform the item removal steps.

Regards,
Todor
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
SlideView
Asked by
Vitalii
Top achievements
Rank 2
Answers by
Vitalii
Top achievements
Rank 2
Todor
Telerik team
Share this question
or