Prism 局部视图 xamarin 表单

Prism Partial views xamarin forms

我正在使用 Prism 构建 xamarin 表单应用程序。 我从未使用过局部视图,也找不到任何示例。

有人可以给我举个例子吗,这样我就可以看看是否适合我想要达到的目标?

非常感谢

来自Docs:

The concept of a Partial View is to support a custom layout which may be reused across multiple pages, and eliminate ViewModel logic duplication by allowing that custom layout to rely on its own ViewModel. To use a Partial View you must set the ViewModelLocator.AutowirePartialView property with a reference to the containing page as shown here. You should not set the ViewModelLocator.AutowireViewModel property on the Partial View unless you are explicitly opting out as setting this property to true directly may result in the ViewModel being incorrectly set.

示例:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:AwesomeApp.Views"
             xmlns:prism="clr-namespace:Prism.Ioc;assembly=Prism.Forms"
             xmlns:mvvm="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             x:Name="self"
             x:Class="AwesomeApp.Views.ViewA">
  <StackLayout>
    <local:AwesomeView mvvm:ViewModelLocator.AutowirePartialView="{x:Reference self}" />
    <Entry Text="{Binding SomeValue" />
  </StackLayout>
</ContentPage>