Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Prevent scrolling to the very ends
posted

I have a horizontal path on my carousel and I want the carousel to always be full - i.e. if there are 12 items and I'm showing 5 at a time, I want the farthest left navigation to show the first 5 items and the farthest right navigation to show the last 5 items.  The default behavior is that the farthest left position shows only the first item and the farthest right shows only the last item.  Any ideas?

David

  • 35
    posted

    I answered my own question.  In case anyone else wants to do this, what I did is that I handled the ExecutingCommand event with the following code:

    if (e.Command == XamCarouselPanelCommands.NavigateToPreviousItem &&
        _DataCarousel.FirstVisibleItemIndex == 0)
    {
        e.Cancel =
    true;
    }
    else if (e.Command == XamCarouselPanelCommands.NavigateToNextItem &&
        _DataCarousel.FirstVisibleItemIndex + _DataCarousel.ItemsPerPageResolved == _DataCarousel.ChildElements.Count)
    {
        e.Cancel =
    true;
    }

    This doesn't work with paging, just single item navigation.  In my case this doesn't matter because I implemented my own navigator that doesn't have paging.