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

Custom Control - Simple Question

$
0
0

I have create a simple application with Two buttons on it (linearLayout and 2 buttons)

If I create a object inherited from class Button, like this:

public class FuckingView : Button { private Paint mPaint;

    public FuckingView (Context context) :
        base (context)
    {
        Initialize ();
    }

    public FuckingView (Context context, IAttributeSet attrs) :
        base (context, attrs)
    {
        Initialize ();
    }

    public void SetPosition(float a, float b)
    {
        p.X = a;
        p.Y = b;
        Invalidate ();
    }

    private PointF p = new PointF();


    public FuckingView (Context context, IAttributeSet attrs, int defStyle) :
        base (context, attrs, defStyle)
    {
        Initialize ();
    }

    void Initialize ()
    {
        Focusable = true;

        //mPaint = new Paint ();
        //mPaint.AntiAlias = true;
    }

    protected override void OnDraw (Canvas canvas)
    {
        //mPaint.Color = Color.Red;
        //canvas.DrawCircle(p.X,p.Y,15,mPaint);
    }
}

And if I replace "<Button" in main.xaml by "FuckingView", the application crashes. So, what do I miss ?

What I want to do at least: Create a application with on one side buttons and stuff like that and on the other side, a drawing view to draw with my finger like a pen....


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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