4
votes

Xamarin Forms in VS 2017. Latest Xamarin Forms.

Following this Blog 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 I added a simple Android TextBox to a page, but it does not appear.

Am I missing something?

<?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>
1
Is the Content declaration <ContentPage.Content> required? Sorry I haven't gotten a chance to really dig into anything xamarin yet but it's the one little detail that stood out in comparison since the rest looks pretty copy/paste verbatim.Chris W.
Once I disabled XAMLC it worked. Thanks ChrisIan Vink
Ah sweet, good to know for the future! cheersChris W.

1 Answers

5
votes

Seems you can't do this if you have XAMLC (XAML compiling) enabled. Once I disabled that it works

You can not enable XamlC on any page that has a native view. You can not use x:Name on any native view control

//NO NO -> [assembly: XamlCompilation(XamlCompilationOptions.Compile)]

see: https://xamarinhelp.com/native-views-xaml-pcl/