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

To maintain the selection after rebind

4 Answers 53 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Shweta Patole
Top achievements
Rank 1
Shweta Patole asked on 14 Jul 2009, 03:00 PM
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

 

4 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 14 Jul 2009, 05:46 PM
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.
0
Shweta Patole
Top achievements
Rank 1
answered on 15 Jul 2009, 08:31 AM
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
0
Milan
Telerik team
answered on 20 Jul 2009, 04:28 PM
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.
0
sridhar
Top achievements
Rank 1
answered on 29 Jun 2011, 01:27 PM
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
Tags
Carousel
Asked by
Shweta Patole
Top achievements
Rank 1
Answers by
Milan
Telerik team
Shweta Patole
Top achievements
Rank 1
sridhar
Top achievements
Rank 1
Share this question
or