ContentPage和ContentView之间的区别

时间:2020-05-31 02:05:50

标签: xamarin.forms

ContentPage和ContentView有什么区别? Visual Studio正在创建从ContentView继承的新类(直到最近它生成了从ContentPage继承的新类)。

例如,Visual Studio的先前版本生成:

public partial class MyContentPage : ContentPage{... }

和:

<?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:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="XamarinPagesApp.Views.MyContentPage">
    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome to Xamarin.Forms!" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

新版本正在生成:

   public partial class MyContentPage : ContentView{... }

和:

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="XamarinPagesApp.Views.MyContentPage">
  <ContentView.Content>
      <StackLayout>
          <Label Text="Welcome to Xamarin.Forms!" />
      </StackLayout>
  </ContentView.Content>
</ContentView>

为什么代码生成器现在表现为这种方式? contentPage和contentView有什么区别?

0 个答案:

没有答案
相关问题