C# xaml中的Android本机视图不';t以Xamarin.Forms显示
我正在尝试添加一个用xaml声明的Android本机视图(Android.Widgets.TextView) 但是,带有本机视图的xaml文件中的IntelisSense显示,Android.Widget和Xamarin.Forms名称空间不存在。当我运行应用程序时,所有运行都不会崩溃或调试输出中出现任何错误,但Android.Widgets.TextView不会显示。我尝试了一个新页面,复制并粘贴了上面链接中的示例,但遇到了相同的问题 这是我的Xaml:C# xaml中的Android本机视图不';t以Xamarin.Forms显示,c#,xaml,xamarin,xamarin.android,xamarin.forms,C#,Xaml,Xamarin,Xamarin.android,Xamarin.forms,我正在尝试添加一个用xaml声明的Android本机视图(Android.Widgets.TextView) 但是,带有本机视图的xaml文件中的IntelisSense显示,Android.Widget和Xamarin.Forms名称空间不存在。当我运行应用程序时,所有运行都不会崩溃或调试输出中出现任何错误,但Android.Widgets.TextView不会显示。我尝试了一个新页面,复制并粘贴了上面链接中的示例,但遇到了相同的问题 这是我的Xaml: <?xml version="1
<?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>
我的目标是Xamarin.Forms包v2.3.4.247。知道它为什么不显示本机视图吗?删除代码中的Xaml编译
//[XamlCompilation(XamlCompilationOptions.Compile)]
如果没有此选项,将显示本机视图。是否已关闭XamlCompilation?尝试将[XamlCompilation(XamlCompilationOptions.Skip)]
添加到您的页面,该页面可以正常工作谢谢!本机视图仍然没有出现在它应该出现的页面上的任何地方,但这是一个不同的xaml问题。在我的例子中,我没有添加[XamlCompilation(XamlCompilationOptions.Skip)],它仍然在工作。