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

SelectedItem ?

8 Answers 243 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 21 Dec 2008, 12:49 AM
When a user selected a current Item or an Item comes into view. How can I call an event to populate a gridview.

For example.. If a Item for John Doe becomes into view or is the selected Caroisel Item - I'd like to make a DB call to grab a dataset of his addresses.

How can I wire up an event to the selected Carousel Item and bind the dataset to the RadGridView.

Thanks again for all your help!!

8 Answers, 1 is accepted

Sort by
0
Hristo Deshev
Telerik team
answered on 22 Dec 2008, 10:11 AM
Hello Jon,

The best approach to tackling this scenario is to handle the SelectionChanged event. In the event args you will get a list of the records added to the selection -- usually a single record. Once you have the record, you can obtain its associated data item, and use the object to retrieve related data from the DB. Here is some code that gets the associated Message object, and pops up a message box with its Subject property value:

private void RadCarousel1_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e) 
    if (e.AddedRecords.Count > 0) 
    { 
        var selectedRecord = (DataRecord) e.AddedRecords[0]; 
        var selectedMessage = (Message) selectedRecord.Data; 
        MessageBox.Show(selectedMessage.Subject); 
    } 
 

I am attaching a sample project with full source code for your reference.

All the best,
Hristo Deshev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
FRANCE GUIMONT
Top achievements
Rank 1
answered on 12 Jul 2009, 06:40 PM
OK, so a mouse click raises the SelectionChanged event, but clicking the scroll bar up or down, or using the keyboard (cursor left or right) to change the item that is into view does not raise that event.  I'd like to be able to bind the item that's in view, so that I can display details, am I missing something, is is there no such property??

Regards
0
Milan
Telerik team
answered on 12 Jul 2009, 08:37 PM
Hi FRANCE GUIMONT,

Currently there is no option that allows the selected item to be bound to the item in view and vice versa but there is a workaround:

private void RadCarousel1_Loaded(object sender, RoutedEventArgs e)  
{  
    this.panel = this.RadCarousel1.FindCarouselPanel();  
    this.panel.IsAnimatingChanged += new RoutedEventHandler(panel_IsAnimatingChanged);  
}  
 
void panel_IsAnimatingChanged(object sender, RoutedEventArgs e)  
{  
    if (!this.panel.IsAnimating)  
    {  
        var record = ((CarouselItem)this.panel.TopContainer).Record;  
        this.RadCarousel1.SelectedRecord = record;  
    }  

Just subscribe to the IsAnimatingChanged event and when the property is false (the panel has finished an animation) just synchronize the selected record.
Unfortunately the IsAnimating property and event are available in our latest releases (Q2 2009, or Q1 2009). Is it possible to upgade your binaries to a more recent version?

Sincerely yours,
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
FRANCE GUIMONT
Top achievements
Rank 1
answered on 13 Jul 2009, 04:40 PM
As a matter of fact, I upgraded the controls last week!  Thanks for the work around, I am now able to update the details based on the carousel item that is in view.
0
FRANCE GUIMONT
Top achievements
Rank 1
answered on 25 Nov 2009, 02:22 PM
With the release of 2009 Q3, this workaround no longer works.  The CarouselItem object no longer exposes a Record property, and the RadCarousel object no longer exposes a SelectedRecord property.  The following event handler for IsAnimatingChanged works:

 

void panel_IsAnimatingChanged(object sender, RoutedEventArgs e)   
{  
    if (!this.panel.IsAnimating)   
    {  
        myRadCarousel.SelectedItem = ((CarouselItem)this.panel.TopContainer).Item as MyDataType;   
    }  
}   
 
 

 

 

 

0
Milan
Telerik team
answered on 26 Nov 2009, 03:31 PM

Hello FRANCE GUIMONT,

This is indeed the correct rework of the code. RadCarousel no longer works with DataRecord but with data items instead which is more natural and easy.

SelectedItem, CurrentITem, and SelectedItems should now be used instead of the old SelectedRecord, CurrentRecord, and SelectedRecords.

Sincerely yours,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
David Lino
Top achievements
Rank 1
answered on 17 May 2010, 02:45 PM
How can I find out the selected item in a RadCarouselPanel hosted in a ScrollViewer?

Thanks
0
Milan
Telerik team
answered on 17 May 2010, 03:55 PM
Hello David Lino,

RadCarouselPanel does not support selection you can use the TopContainer property to get the container that is in the middle of the carousel.

Alternatively you can use RadCarousel which is a full-blown data control and supports selection among other things.

Sincerely yours,
Milan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Carousel
Asked by
Jon
Top achievements
Rank 1
Answers by
Hristo Deshev
Telerik team
FRANCE GUIMONT
Top achievements
Rank 1
Milan
Telerik team
David Lino
Top achievements
Rank 1
Share this question
or