Reputation: 732
I'm trying at add an Android native view (Android.Widgets.TextView) declared in xaml. I was following the Xamarin documentation here.
However Intelisense in the xaml file with the native view shows Android.Widget and Xamarin.Forms namespaces don't exist. When I run the app everything run's without crashing or any errors in the debug output but the Android.Widgets.TextView does not display. I tried a new page and copy and pasted the example from the link above but had the same issues.
Here is my Xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CrucialExams.Xamarin.Views.FlashCardsPage"
xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
xmlns:views="clr-namespace:CrucialExams.Xamarin.Views;assembly=CrucialExams.Xamarin"
xmlns:androidWidget="clr-namespace:Android.Widget;assembly=Mono.Android;targetPlatform=Android"
xmlns:formsAndroid="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.Platform.Android;targetPlatform=Android"
Title="{Binding Title}"
BackgroundColor="{StaticResource LightBackgroundColor}"
Padding="0">
<ContentPage.Content>
<androidWidget:TextView Text="Native Text" x:Arguments="{x:Static formsAndroid:Forms.Context}" />
<Grid Margin="3" Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="9*" />
</Grid.RowDefinitions>
<!--<views:PercentageBarView BackgroundColor="Red" Grid.Row="0"></views:PercentageBarView>-->
<controls:CarouselViewControl Grid.Row="1"
x:Name="Carousel"
Margin="0"
Position="0"
ItemsSource="{Binding Pages}"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<controls:CarouselViewControl.ItemTemplate>
<DataTemplate>
<Grid Margin="3" Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="10*" />
</Grid.RowDefinitions>
<Frame HasShadow="True" Margin="5" Grid.Row="0">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="OnCardTapped"/>
</Frame.GestureRecognizers>
<Label Margin="5"
FontSize="25"
Text="{Binding CurrentText}"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center" />
</Frame>
</Grid>
</DataTemplate>
</controls:CarouselViewControl.ItemTemplate>
</controls:CarouselViewControl>
</Grid>
</ContentPage.Content>
</ContentPage>
And Intelisense:
I'm targeting Xamarin.Forms package v2.3.4.247. Any ideas why it's not showing the native view?
Upvotes: 2
Views: 916
Reputation: 2266
Remove Xaml Compilation in your code behind
//[XamlCompilation(XamlCompilationOptions.Compile)]
Without this, your native view will appear.
Upvotes: 1