【问题标题】:How to add an Image side to the back button in navigation bar如何将图像侧添加到导航栏中的后退按钮
【发布时间】:2019-12-11 02:12:54
【问题描述】:

我正在研究 xamarin。表单应用程序,我需要在其中添加图像侧 导航栏中的后退按钮。

我试过了 1. <NavigationPage.TitleView><image/></NavigationPage.TitleView> - 这里的视图远离后退按钮。后退按钮和图像之间的空间更大。 2. 创建如下自定义导航。

            <Grid BackgroundColor="{Binding ActionbarColor}">
            <StackLayout Orientation="Horizontal" Spacing="0" HeightRequest="60" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <Image Source="back.png" HeightRequest="20" WidthRequest="20" HorizontalOptions="Start" VerticalOptions="CenterAndExpand">
                    <Image.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding MoveBackCommand}"></TapGestureRecognizer>
                    </Image.GestureRecognizers>
                </Image>
                <Imge Source="defaultUser.png">
                <Label />
                <Label  x:Name="TitleLabel" VerticalTextAlignment="Center" VerticalOptions="CenterAndExpand" TextColor="White" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="FillAndExpand"/>
            </StackLayout>
        </Grid>

使用 2nd,导航到后视图时视图会闪烁。

除了这两种之外,还有什么方法可以在导航栏的后退按钮旁边显示图像

【问题讨论】:

    标签: image xamarin.forms navigationbar


    【解决方案1】:

    使用网格来改变

    <Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ColumnSpacing="0">
      <Grid.RowDefinitions>
        <RowDefinition Height="50"/>
      </Grid.RowDefinitions>
      <BoxView BackgroundColor="Aqua" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="5"/>
      <Button Image="BackIcon" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="1" Command="GoBack"/>
      <Image Source="Logo" Aspect="AspectFit" BackgroundColor="Transparent" Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="1"/>
    </Grid>
    

    它不起作用跟随this - 如果它起作用,请告诉我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-23
      • 2019-08-28
      • 1970-01-01
      • 1970-01-01
      • 2021-07-12
      相关资源
      最近更新 更多