TopItem Clicked event for RadCarousel

3 posts, 0 answers
  1. Ela
    Ela avatar
    12 posts
    Member since:
    Jul 2010

    Posted 03 Aug 2010 Link to this post

    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. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Aug 2010 Link to this post

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

    Posted 05 Aug 2010 Link to this post

    Thanks Maya. It helped.
Back to Top