Detect Tap on Gauge

6 posts, 1 answers
  1. N Mackay
    N Mackay avatar
    250 posts
    Member since:
    Dec 2010

    Posted 02 Jun Link to this post

    Hi,

    How do you detect a tap on a gauge?

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

    Thanks.

  2. Answer
    Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    414 posts

    Posted 05 Jun Link to this post

    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
  3. N Mackay
    N Mackay avatar
    250 posts
    Member since:
    Dec 2010

    Posted 05 Jun in reply to Lance | Tech Support Engineer, Sr. Link to this post

    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.

  4. N Mackay
    N Mackay avatar
    250 posts
    Member since:
    Dec 2010

    Posted 06 Jun in reply to N Mackay Link to this post

    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.

  5. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    414 posts

    Posted 06 Jun Link to this post

    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
  6. N Mackay
    N Mackay avatar
    250 posts
    Member since:
    Dec 2010

    Posted 07 Jun in reply to Lance | Tech Support Engineer, Sr. Link to this post

    Hi Lance,

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

Back to Top