Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Carousel > To maintain the selection after rebind

Not answered To maintain the selection after rebind

Feed from this thread
  • Shweta Patole avatar

    Posted on Jul 14, 2009 (permalink)

    Hi,

    This is really urgent.

    I want to maintain the selection of the item of carousal after its rebound or refreshed.

    PLease find the code below which is not working;

    int

     

    iSelIndex = rdcTasks.Records.IndexOf(rdcTasks.SelectedRecord);
    this.rdcTasks.ItemSource = list;

     

    RadCarouselPanel

     

    panel = this.rdcTasks.FindCarouselPanel();

     

    panel.BringDataItemIntoView(rdcTasks.Records[iSelIndex]);

     

    this.rdcTasks.Records[iSelIndex].IsSelected = true;

    I have tried other properties like currentItem & Currentrecord but no gain.

    REgards,
    S

     

    Reply

  • Milan Milan admin's avatar

    Posted on Jul 14, 2009 (permalink)

    Hi Shweta Patole,

    You can try the following:

    var selectedIndex = this.RadCarousel1.Records.IndexOf(this.RadCarousel1.SelectedRecord);  
    this.RadCarousel1.SelectedRecord = null;  
    this.RadCarousel1.ItemsSource = myNewSource  
     
    this.Dispatcher.BeginInvoke(new Action(() =>  
        {  
            this.RadCarousel1.SelectedRecord = this.RadCarousel1.Records[selectedIndex];  
        }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);  
     

    Hope this works.


    Greetings,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Shweta Patole avatar

    Posted on Jul 15, 2009 (permalink)

    Hi

    Thanks for your prompt reply.

    I have tried the same thing, but there is a movement in te control. it moves to the first record and then moves back to the selected one. Is there any way to stop this so that user wouldnt know whats happening?
    Regards,
    Shweta

    Reply

  • Milan Milan admin's avatar

    Posted on Jul 20, 2009 (permalink)

    Hi Shweta Patole,

    You could try setting the animation duration to zero and hiding the panel before the animation and after that restore the visibily and the duration. That might improve the experience but still there will be a single flicker. Here is a sample code:

    public void Rebind()  
    {  
        var panel = this.RadCarousel1.FindCarouselPanel();  
        var duration = panel.ItemsMovementAnimationDuration;  
        panel.ItemsMovementAnimationDuration = TimeSpan.Zero;  
        var selectedIndex = this.RadCarousel1.Records.IndexOf(this.RadCarousel1.SelectedRecord);  
        this.RadCarousel1.SelectedRecord = null;     
        this.RadCarousel1.ItemsSource = null;  
        this.RadCarousel1.ItemsSource = data;  
        panel.Visibility = Visibility.Hidden;  
     
        this.Dispatcher.BeginInvoke(new Action(() =>  
            {  
                this.RadCarousel1.SelectedRecord = this.RadCarousel1.Records[selectedIndex];  
            }),  System.Windows.Threading.DispatcherPriority.SystemIdle, null);  
     
        this.Dispatcher.BeginInvoke(new Action(() =>  
        {  
            panel.Visibility = Visibility.Visible;  
            panel.ItemsMovementAnimationDuration = duration;  
        }), System.Windows.Threading.DispatcherPriority.SystemIdle, null);  
     

    We will try to provide a better support for such scenarios in the future.

    Greetings,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • sridhar avatar

    Posted on Jun 29, 2011 (permalink)

    Hello,

            I have been using the rad carousal in a wpf application. I am unable to maintain the selected item of previous session, i.e when i select an item , then close the appln and then open i am not seeing the selected item.
    please help me.
     Thanks
    Sridhar

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Carousel > To maintain the selection after rebind
Related resources for "To maintain the selection after rebind"

WPF Carousel Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]