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

TopItem Clicked event for RadCarousel

2 Answers 76 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Ela
Top achievements
Rank 1
Ela asked on 03 Aug 2010, 06:18 PM
Hi,

The SelectionChanged event of RadCarousel works only when the Non-Top item is selected. Is there a event/way to know when the user clicks on the Top item? Currently I'm using the DoubleClicked event to check for the Top item's property, to identify it. But, I want to know whether I can handle it with a single click.

Thanks in advance.
Ela

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 05 Aug 2010, 03:00 PM
Hello Ela,

What you can do in this case is to AddHandler and handle the PreviewMouseLeftButtonUp event. For example:

public partial class MainWindow : Window
{
  public MainWindow()
  {
    InitializeComponent();
    this.MyCarousel.ItemsSource = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
 
 
    this.MyCarousel.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(MyCarousel_PreviewMouseLeftButtonUp);
    this.AddHandler(RadCarousel.MouseLeftButtonUpEvent, new MouseButtonEventHandler(MyCarousel_PreviewMouseLeftButtonUp));
   }
 
void MyCarousel_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    UIElement source = e.OriginalSource as UIElement;
 
    var carouselItem = source.ParentOfType<CarouselItem>();
    if (carouselItem != null && carouselItem == this.MyCarousel.FindCarouselPanel().TopContainer)
    {
        MessageBox.Show("Clicked is Top Item");
    }
  }
}

 
Thus in this case when the top item is clicked a message will be shown. However, you can apply whatever logic you need.


Regards,
Maya
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
0
Ela
Top achievements
Rank 1
answered on 05 Aug 2010, 03:34 PM
Thanks Maya. It helped.
Tags
Carousel
Asked by
Ela
Top achievements
Rank 1
Answers by
Maya
Telerik team
Ela
Top achievements
Rank 1
Share this question
or