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
565
Forcing selection to foremost carousel item
posted

Is there a way for force the selection to the foremost carousel item?

I have a few control in four panels, and I don't want to have the control enabled that aren't in the foreground (highest z-order).  Consequently every time the foremost item changes I want to disable the old item, and enable the new foremost item.

There don't seem to be any events notifying of change in position of the carousel.

Any help would be appreciated.

Douglas Gerard

 

Parents
No Data
Reply
  • 2677
    posted

    Hello,

     I have some code here that will enable and disable the carousel items based on the center position, not the z order.  All you have to do is wire up the RecyclingItemContainerGenerator_StatusChanged event.  Then, all you have to do is loop throught the items and enable/disable based on the index of the item compared to the centerposition added to the vertical offset.

    this.XamCarouselListBox1.RecyclingItemContainerGenerator.StatusChanged += new EventHandler(RecyclingItemContainerGenerator_StatusChanged);

    void RecyclingItemContainerGenerator_StatusChanged(object sender, EventArgs e)
            {
                for (int i = 0; i < XamCarouselListBox1.Items.Count; i++)
                {
                    int centerPositionOffset = this.XamCarouselListBox1.ViewSettings.ItemsPerPage / 2;
                    CarouselListBoxItem clbi = (CarouselListBoxItem)XamCarouselListBox1.RecyclingItemContainerGenerator.ContainerFromIndex(i);
                   
                    if (clbi != null && i != centerPositionOffset + this.XamCarouselListBox1.ScrollInfo.VerticalOffset)
                    {
                        clbi.IsEnabled = false;
                      
                      
                    }
                    else if (clbi != null && i == centerPositionOffset + this.XamCarouselListBox1.ScrollInfo.VerticalOffset)
                        clbi.IsEnabled = true;

                }
            }

    Give the code a shot and let me know what you think.

Children
No Data