【问题标题】:Fixed header for list and detail page. Xamarin Forms修复了列表和详细信息页面的标题。 Xamarin 表单
【发布时间】:2018-11-29 10:42:24
【问题描述】:

我有一个 Xamarin Forms 应用程序。在里面我有一个带有 ListView 和标题的页面(一个有几行的网格)。此标题应该与详细信息页面相同。通过单击列表视图中的项目导航到详细信息页面。

它们的标题完全相同。所以我想让标题保持静态,在从列表更改为详细信息时,我只想更改标题下方的内容,而标题保持在同一个地方)。

如果有人以前做过类似的事情或知道更好的方法 - 我将非常感激能得到一些想法。

【问题讨论】:

  • 您可以使用 contentview 创建一次标题并在您想要的任何地方重复使用它。

标签: c# xamarin xamarin.forms


【解决方案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>

【讨论】:

    猜你喜欢
    • 2016-09-20
    • 1970-01-01
    • 2014-09-26
    • 1970-01-01
    • 2019-06-28
    • 1970-01-01
    • 2016-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多