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="WPapp.Views.Home"
x:Name="HomeHeader">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Refresh"
x:Name="refreshButton"
Clicked="refreshButton_Clicked"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<ScrollView>
<StackLayout Margin="10"
HorizontalOptions="Center"
VerticalOptions="FillAndExpand"
x:Name="HomeContainer">
<Label Text="Featured Posts"
FontSize="Title"
FontAttributes="Bold"
Margin="0, 20, 10, 0"/>
<CarouselView>
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout x:Name="FeaturedContainer"/>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>
使用 c# 文件中的这一行,
FeaturedContainer.Children.Clear();
我收到以下错误:
错误 CS0103:当前上下文中不存在名称“FeaturedContainer”(CS0103)
我究竟做错了什么?