SelectedItem ?

9 posts, 0 answers
  1. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 20 Dec 2008 Link to this post

    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!!
  2. Hristo Deshev
    Admin
    Hristo Deshev avatar
    559 posts

    Posted 22 Dec 2008 Link to this post

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

    Posted 12 Jul 2009 Link to this post

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

    Posted 12 Jul 2009 Link to this post

    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.
  6. FRANCE GUIMONT
    FRANCE GUIMONT avatar
    3 posts
    Member since:
    Jan 2009

    Posted 13 Jul 2009 Link to this post

    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.
  7. FRANCE GUIMONT
    FRANCE GUIMONT avatar
    3 posts
    Member since:
    Jan 2009

    Posted 25 Nov 2009 Link to this post

    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;   
        }  
    }   
     
     

     

     

     

  8. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 26 Nov 2009 Link to this post

    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.
  9. David Lino
    David Lino avatar
    13 posts
    Member since:
    Apr 2010

    Posted 17 May 2010 Link to this post

    How can I find out the selected item in a RadCarouselPanel hosted in a ScrollViewer?

    Thanks
  10. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 17 May 2010 Link to this post

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