Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Xamarin Derived UIControl TouchUpInside event isn't working

$
0
0

I'm trying to set an TouchUpInside event to my class that inherit from UIControl.

First, I've tried to set the event to each control separately, in the same class, and it's also not working. Than, I've tried to set the event from the window that present this UIControl, but also isn't working.

The class drawing two controls, Button and TextField: public class SingleItemView : UIControl { public UIButton RadioButton { get; set; }

    public override void Draw(RectangleF rect)
    {
        base.Draw(rect);
        this.UserInteractionEnabled = true;

        RadioButton = new UIButton(rect);
        RadioButton.SetImage(UIImage.FromFile("images/Unknown_Gray.png"), UIControlState.Normal);
        RadioButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
        this.AddSubview(RadioButton);

        var textField = new UITextField(new RectangleF(rect.X + 25, rect.Y, rect.Width, rect.Height));
        textField.Placeholder = "Place Holder is here";
        this.AddSubview(textField);
    }   
}

The ViewController that signs the event:

public class ItmesView : UIViewController
{
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        var item = new SingleItemView();
        item.Draw(new RectangleF(10, 60, 50, 30));
        item.TouchUpInside += item_TouchUpInside;
        this.View.AddSubview(item); 
    }
}

None of the events I've tried isn't working, any suggestion?

Thanks.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>