Forum Xamarin.Android

how to override View.setFrame ?

softlionsoftlion FRBeta ✭✭✭ defines a SetFrame method, ImageView overrides this method (marked as hidden).

How to override this method in xamarin ?


  • UnreachableCodeUnreachableCode USMember ✭✭✭
    edited April 6

    It's a property, rather than a method, in C#. So you can override it like so:

    public override CGRect Frame
            if (Superview != null)
                base.Frame = new CGRect(0, 0, this.Superview.Bounds.Size.Width, this.Superview.Bounds.Size.Height);

    Notice I've left the get out as I only want to override the set. And make sure you call the base.Frame instead of Frame, otherwise, you'll cause an infinite loop of setting Frame.

Sign In or Register to comment.