固定的列表和详细信息页眉。 Xamarin表格

时间:2018-11-29 10:42:24

标签: c# xamarin xamarin.forms

我有Xamarin Forms应用程序。里面我有带ListView和页眉的页面(带有几行的网格)。该标题对于详细信息页面应该是相同的(单击列表中的一项,我们将进入详细信息页面)。它们的标题完全相同,因此我想使其变为静态,并且在从列表更改为详细信息的同时,我只希望更改标题下方的内容,但标题保留在同一位置)。如果有人以前做过这样的事情,或者知道如何做得更好-我将非常感谢获得一些想法。预先谢谢你。

1 个答案:

答案 0 :(得分:1)

ControlTemplate正是您所需要的。它使您可以设置一个布局,当ContentView使用ControlTemplate时,可以将其添加到其中。

<ControlTemplate x:Key="Template">
    <Grid>
        <!-- Set up your grid -->
    </Grid>
    <!-- When this control template is used by a 
         ContentView, the layout in the ContentView 
         will appear where the below ContentPresenter is -->
    <ContentPresenter ... />
</ControlTemplate>

然后在ContentView中使用它(它必须在ContentView中,不能直接在ContentPage中)

<ContentView ControlTemplate="{StaticResource Template}">
   <!-- The below will appear where ContentPresenter element is in the
        ControlTemplate -->
    <ListView ...>
       ...
    </ListView>
</ContentView>
相关问题