如何在选项卡上方的TabbedPage中添加按钮

3
这是否可能创建?我需要在选项卡上方添加2个按钮,如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"          
    xmlns:local ="clr-namespace:SembIWIS.View"  
       x:Class="myApp.MainPage">

  <local:ProductPage>
  </local:ProductPage>

  <local:ServicePage>
  </local:ServicePage>

</TabbedPage>

How to add two buttons in the TabbedPage, so It will look like :

 |----------------------|
 | TabbedPage           |
 |----------------------|
 |                      |
 |  btn1        btn2    |
 |                      |
 |----------------------|
 | Tab1 | tab2 | tab3 ..|
 |----------------------|
 |                      |
 |                      |
 |                      | 
 ------------------------

你有没有解决这个问题的方案?我必须在当前需求中实现相同的功能。 - Suresh Sharma
1个回答

0

是的,这是可以做到的。您可以使用简单的Grid结构,也可以使用StackLayouts并设置VerticalOptions = EndAndExpand来实现。以下是Grid版本:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid Grid.Row="0">
        // Normal content
    </Grid>
    <Grid Grid.Row="1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Button Grid.Column="0" Text="Button 1" />
        <Button Grid.Column="1" Text="Button 2" />
    </Grid>
</Grid>

将Grid标签放在哪里?在第一个选项卡(ProductPage)上面吗?ProductPage是一个普通的XAML页面。 - MilkBottle
它应该放在每个需要它的页面内。如果您想将其作为选项卡页面的一部分,则需要查看自定义渲染器,以使用您自己的实现覆盖默认的TabbedPage。 - Steven Thewissen
我需要将按钮放在选项卡之外。如何实现?使用哪个自定义渲染器。你能指导我吗? - MilkBottle
这个问题没有一成不变的答案。它完全取决于您的需求,需要进行完全定制的实现。请阅读有关Xamarin Forms自定义渲染器的内容,网址为https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/。 - Steven Thewissen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接