Display Custom View in Designer

Nathan Sokalski 4,111 Reputation points
2022-10-12T03:10:04.457+00:00

I have a Custom View (a class that inherits from View). I override the OnDraw method, but there are very few things I can do there that do not cause errors in the designer. I understand that this is because some things are not available during design time, but I know there must be some way to do simple things like display a drawable. However, I am not sure how to do much in OnDraw that can be visible during design time. Any ideas?

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2022-10-13T06:06:07.797+00:00

    Hello,

    There is no possible to display custom view in designer.

    The Xamarin.Android designer is only working for XML files, please refer to Xamarin.Android Designer to get more details.

    Xamarin.Android supports both a declarative style of user interface design based in XML files, as well as programmatic user interface creation in code. When using the declarative approach, XML files can be either hand-edited or modified visually by using the Xamarin.Android Designer.

    When you overrode OnDraw method, even minor changes it needed to be recompiled.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.