部分声明不能在Xamarin中指定其他基类

时间:2019-02-01 15:37:43

标签: visual-studio xaml user-interface xamarin

我正在构建Xamarin跨平台应用程序

对于抽屉菜单,我正在学习本教程:https://www.youtube.com/watch?v=aYjK0cPjZMQ

但问题是,当我改变我的MainPageContentPageMasterDetailPage它表明我这个错误:

enter image description here

MainPage.xaml中:

    <?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Last_MSPL"
             x:Class="Last_MSPL.MainPage">

    <MasterDetailPage.Master>
        <ContentPage Title="Menu">
            <Grid BackgroundColor="Transparent">
                <Grid.RowDefinitions>
                    <RowDefinition Height="200" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid>
                    <Image Source="bg.png" Aspect="AspectFill" />
                    <StackLayout Padding="0,20,0,0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
                        <Image Source="profile.png" Aspect="AspectFill" WidthRequest="85" HeightRequest="85" />
                        <Label Text="Xam Buddy" TextColor="White" FontSize="Large" />
                    </StackLayout>
                </Grid>
                <StackLayout  Grid.Row="1" Spacing="15">
                    <ListView x:Name="navigationDrawerList"
                  RowHeight="60"
                  SeparatorVisibility="None"
                  BackgroundColor="#e8e8e8"
                  ItemSelected="OnMenuItemSelected">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <!-- Main design for our menu items -->
                                    <StackLayout VerticalOptions="FillAndExpand"
                             Orientation="Horizontal"
                             Padding="20,10,0,10"
                             Spacing="20">
                                        <Image Source="{Binding Icon}"
                         WidthRequest="40"
                         HeightRequest="40"
                         VerticalOptions="Center" />
                                        <Label Text="{Binding Title}"
                         FontSize="Small"
                         VerticalOptions="Center"
                         TextColor="Black"/>
                                    </StackLayout>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </StackLayout>
            </Grid>
        </ContentPage>
    </MasterDetailPage.Master>
    <MasterDetailPage.Detail>
        <NavigationPage>
        </NavigationPage>
    </MasterDetailPage.Detail>

</MasterDetailPage>

帮我解决这个问题,以便我继续前进,谢谢!

1 个答案:

答案 0 :(得分:3)

我只是清理我的项目,然后重新构建就可以了 因为从xaml生成的.g.cs尚未刷新,所以出现了此错误