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

Detect Tap on Gauge

5 Answers 37 Views
Gauges
This is a migrated thread and some comments may be shown as answers.
N Mackay
Top achievements
Rank 1
N Mackay asked on 02 Jun 2017, 01:52 PM

Hi,

How do you detect a tap on a gauge?

Can't find an event to hook into or a gesturerecognizer support?

Thanks.

5 Answers, 1 is accepted

Sort by
0
Accepted
Lance | Manager Technical Support
Telerik team
answered on 05 Jun 2017, 06:31 PM
Hello Norman,

You can use the Xamarin GestureRecognizers for this. I've attached a demo for you where tapping the gauge updates a Label's Text with the tapped count (wait for the app to completely load before starting to tap, the recognizer is one of the last things to fire up).

This is the code for hooking up the TapGestureRecognizer:

ContentPage XAML:

<telerikGauges:RadRadialGauge x:Name="gauge" >

ContentPage code behind:

protected override void OnAppearing()
{
    base.OnAppearing();
 
    var tapGestureRecognizer = new TapGestureRecognizer();
    tapGestureRecognizer.Tapped += TapGestureRecognizer_Tapped;
 
    // Add the recognizer to the View's GestureRecognizers IList
    gauge.GestureRecognizers.Add(tapGestureRecognizer);
}
 
private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
    // do work
}


If this answers your question, you can let me know by selecting "Mark as resolved" and I'll close the ticket for you. If you have trouble with it, please share the code that isn't working and I'll debug it directly.

Thank you for contacting Support and for choosing UI for Xamarin

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
0
N Mackay
Top achievements
Rank 1
answered on 05 Jun 2017, 07:10 PM

HI Lance,

Thanks for the sample.

That works, for whatever reason my resharper couldn't pickup the gesture recognizer in XAML for the gauge, I ended up using the GestureRecognizer of the StackLayout behind, I'll revisit it and try again, I try and avoid code behind where possible.

Thanks again,

Norman.

0
N Mackay
Top achievements
Rank 1
answered on 06 Jun 2017, 05:32 PM

Hi Lance,

No idea why my resharper could't find the gesture recognizers for that control but it works fine now in XAML.

</telerikGauges:RadRadialGauge.Ranges>
        <telerikGauges:RadRadialGauge.GestureRecognizers>
            <TapGestureRecognizer
                Command="{Binding PerformanceCommand}" />
        </telerikGauges:RadRadialGauge.GestureRecognizers>
    </telerikGauges:RadRadialGauge>

Thanks.

0
Lance | Manager Technical Support
Telerik team
answered on 06 Jun 2017, 06:29 PM
Hi Norman,

I can relate,  R# can be a little undependable sometimes when in Xamarin.Forms XAML. Many times I have to type out the XAML without the benefit of R# autocomplete it. Additionally, sometimes R# will even mark the code as error colored although there is no real error (this happens in C# as well).

I happy to see you're where you want to be. Please let us know if you have any further trouble.

Side Note:
I noticed you posted this in a forum post instead of a support ticket, you have a full UI for Xamarin support license and can open support tickets here.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
0
N Mackay
Top achievements
Rank 1
answered on 07 Jun 2017, 10:50 AM

Hi Lance,

I've very familiar with the support portal, I have 46500 Telerik points :)

Tags
Gauges
Asked by
N Mackay
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
N Mackay
Top achievements
Rank 1
Share this question
or