How to double click a selected image from de carousel?

4 posts, 0 answers
  1. Adrian Guillen
    Adrian Guillen avatar
    5 posts
    Member since:
    Nov 2009

    Posted 30 Nov 2009 Link to this post

    If a click an image on the radcarousel how do I do to open a window or a dialog when I double click the selected image item of the carousel?
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 01 Dec 2009 Link to this post

    Hello Adrian Guillen,

    The MouseDown events args provide a property CLickCount which can be used to detect multiple clicks. 

    <telerik:RadCarouselPanel>
        <Image Width="50" Height="50" Source="1.jpg" MouseDown="Image_MouseDown"/>
        <Image Width="50" Height="50" Source="2.jpg" MouseDown="Image_MouseDown"/>
        <Image Width="50" Height="50" Source="3.jpg" MouseDown="Image_MouseDown"/>
        <Image Width="50" Height="50" Source="4.jpg" MouseDown="Image_MouseDown"/>
    </telerik:RadCarouselPanel>

    private void Image_MouseDown(object sender, MouseButtonEventArgs e)
    {
        if (e.ClickCount == 2)
        {
            // open window
        }
    }

    Hope this helps.

    Kind regards,
    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Adrian Guillen
    Adrian Guillen avatar
    5 posts
    Member since:
    Nov 2009

    Posted 01 Dec 2009 Link to this post

    Thank you for your help and quickness in your response, but i´m using the carousel, not the carousel panel. And have a list of images as the itemsource for the carousel. If you know how to do it in my case i'll appreciate your help. Thank you
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 04 Dec 2009 Link to this post

    Hello Adrian Guillen,

    Here is how it can be done when using RadCArousel instead of RadCarouselPanel:

    public Window1()
    {
        InitializeComponent();
      
        RadCarousel1.ItemsSource = new[] 
        {
            new BitmapImage(new Uri("online.png",  UriKind.Relative)),
            new BitmapImage(new Uri("online.png",  UriKind.Relative)),
            new BitmapImage(new Uri("online.png",  UriKind.Relative)),
            new BitmapImage(new Uri("online.png",  UriKind.Relative))
        };
      
        this.RadCarousel1.AddHandler(FrameworkElement.MouseDownEvent, 
            new MouseButtonEventHandler(OnMouseDown), true);
    }
      
    private void OnMouseDown(object sender, MouseButtonEventArgs e)
    {
        var sourceElement = e.OriginalSource as FrameworkElement;
        var carouselItem = sourceElement.ParentOfType<CarouselItem>();
      
        if (carouselItem != null && e.ClickCount >= 2)
        {
            // open window
        }
    }

    Hope this helps.

    Regards,
    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.
Back to Top