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

How to double click a selected image from de carousel?

3 Answers 137 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Adrian Guillen
Top achievements
Rank 1
Adrian Guillen asked on 30 Nov 2009, 10:13 PM
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?

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 01 Dec 2009, 04:23 PM
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.
0
Adrian Guillen
Top achievements
Rank 1
answered on 01 Dec 2009, 10:47 PM
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
0
Milan
Telerik team
answered on 04 Dec 2009, 07:29 AM
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.
Tags
Carousel
Asked by
Adrian Guillen
Top achievements
Rank 1
Answers by
Milan
Telerik team
Adrian Guillen
Top achievements
Rank 1
Share this question
or