简体   繁体   中英

Xamarin Android, custom control and Visual Studio designer

I have created a custom control in Xamarin using Visual Studio and C#. The Custom control works perfectly and the code is quite simple:

[DesignTimeVisible(true)]
public class CustomTextView : TextView
{
    public CustomTextView(Context context)
        :base(context)
    {

    }

    public CustomTextView(Context context, IAttributeSet attrs)
        :base(context,attrs)
    {

    }

    public CustomTextView(IntPtr javaReference, JniHandleOwnership transfer)
        :base(javaReference, transfer)
    {

    }

    public CustomTextView(Context context, IAttributeSet attrs, int defStyle)
        :base(context, attrs, defStyle)
    {

    }
}

Problem is that in design time, xamarin designer render the control in the following way, so it becomes useless for me because I cannot understand how it will look at run-time. 在此输入图像描述

Is this a limitation of the Designer for Visual Studio or can I do something about it?

As you've already noted - its a current limitation (Nov 2014) of the designer for Visual Studio for Android .

Unfortunately you will have to run on a device or emulator to see the render output.

In iOS it is now possible to render custom controls at design-time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM