Draw not called on UIView with Invisible parent.

LippelLippel DEMember ✭✭
edited March 2018 in Xamarin.iOS

I have a grid that holds multiple Buttons.
I have a customrenderer for the Buttons (ButtonRenderer). Inside this customrenderer, I have overriden the Draw(Rect rect) method.
However Draw does not get called, if the parent grid has IsVisible set to false when the buttons get initialized.
Also when the grid changes the IsVisible property, the Draw method is still not being called, therefore the buttons remain undrawn.

How can I make the buttons get drawn?
Do I have to manually climb up the view hierachy on initialization and look for a parent and then check for the IsVisible property? This would be kind of a mess

Best Answer

  • LippelLippel DE ✭✭
    Accepted Answer

    I have found the answer.
    All I have to do is set the ContentMode to UIViewContentMode.Redraw

    //Ctor
    public CustomUIView() 
    {
        ContentMode = UIViewContentMode.Redraw;
    }
    

Answers

  • LippelLippel DEMember ✭✭
    Accepted Answer

    I have found the answer.
    All I have to do is set the ContentMode to UIViewContentMode.Redraw

    //Ctor
    public CustomUIView() 
    {
        ContentMode = UIViewContentMode.Redraw;
    }
    
Sign In or Register to comment.