Xamarin.Forms XAML - 添加Native控件

Ian*_*ink 4 xaml android xamarin.android xamarin xamarin.forms

VS 2017中的Xamarin表格.最新的Xamarin表格.

关注此博客https://blog.xamarin.com/adding-bindable-native-views-directly-to-xaml/?utm_medium=social&utm_campaign=blog&utm_source=twitter&utm_content=xaml-bindable-native-views我添加了一个简单的Android TextBox一个页面,但它没有出现.

我错过了什么吗?

<?xml version="1.0" encoding="utf-8"?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:androidWidget="clr-namespace:Android.Widget;assembly=Mono.Android;targetPlatform=Android"
         xmlns:formsandroid="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.Platform.Android;targetPlatform=Android"
         xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
         xmlns:widget="clr-namespace:Android.Support.Design.Widget;assembly=Xamarin.Android.Support.Design"
         x:Class="Muffin.MainPage">

<StackLayout> 
     <androidWidget:TextView x:Arguments="{x:Static formsandroid:Forms.Context}" Text="this is the text" />
</StackLayout>
Run Code Online (Sandbox Code Playgroud)

Ian*_*ink 5

如果您启用了XAMLC(XAML编译),则似乎无法执行此操作.一旦我禁用它,它的工作原理

您无法在具有本机视图的任何页面上启用XamlC.您不能在任何本机视图控件上使用x:Name

//NO NO -> [assembly: XamlCompilation(XamlCompilationOptions.Compile)]
Run Code Online (Sandbox Code Playgroud)

请参阅:https: //xamarinhelp.com/native-views-xaml-pcl/