To maintain the selection after rebind

5 posts, 0 answers
  1. Shweta Patole
    Shweta Patole avatar
    4 posts
    Member since:
    Jul 2009

    Posted 14 Jul 2009 Link to this post

    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

     

  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 14 Jul 2009 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Shweta Patole
    Shweta Patole avatar
    4 posts
    Member since:
    Jul 2009

    Posted 15 Jul 2009 Link to this post

    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
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 20 Jul 2009 Link to this post

    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.
  6. sridhar
    sridhar avatar
    1 posts
    Member since:
    Jun 2011

    Posted 29 Jun 2011 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready