请帮助我解决以下问题。
这是我的问题。如果没有动画就推送(false),然后是问题。如果动画为true,则工作正常。
// await Navigation.PushAsync<DeleteDealsAndOffersViewModel>(); --> **working fine**
// await Navigation.PushAsync(new DeleteDealsAndOffersViewModel());**working fine**
vm = new DeleteDealsAndOffersViewModel
{
DealsAndOffersList = dealLists,
//CategoryColor = CategoryColor,
IsDelete = true
};
//await Navigation.PushAsync(vm,false); **issue with back button**
我为后退按钮使用了以下代码。这是我的基类。
<?xml version="1.0" encoding="UTF-8"?>
<v:ExtendedContentPage
xmlns:v="clr-namespace:Core.Views;assembly=Core"
xmlns="http://xamarin.com/schemas/2014/forms"
LeftBarButtonTitle="< Back"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Vi.Views.BasicV">
<ContentPage.Content>
</ContentPage.Content>
</v:ExtendedContentPage>
now I create another page and set base class on that page
DeleteDealsAndOffersListPage.xaml
<?xml version="1.0" encoding="UTF-8"?>
<view:BasicV
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:view="clr-namespace:Vi.Views;assembly=FlagSpree"
xmlns:sty="clr-namespace:VillageVesl.Styles;assembly=FlagSpree"
xmlns:v="clr-namespace:Core.Views;assembly=Core"
xmlns:comp="clr-namespace:VillageVesl.Views.Components;assembly=FlagSpree"
x:Name="main" Title="{Binding Title}"
LeftBarButtonTitle="Cancel"
BackgroundColor="{x:Static sty:Colors.BGColor}"
x:Class="Vi.Views.DeleteDealsAndOffersListPage">
<ContentPage.ToolbarItems>
<ToolbarItem IsDestructive="true" Text="Delete" Command="{Binding DeleteAllSelectedDealsCommand}" />
</ContentPage.ToolbarItems>
<ContentPage.Content>
</ContentPage.Content>
</view:BasicV>
“ DeleteDealsAndOffersListPage.xaml.cs” 。
namespace Vi.Views
{
public partial class DeleteDealsAndOffersListPage : BasicV
{
public DeleteDealsAndOffersListPage()
{
InitializeComponent();
}
}
}
现在的问题是,当我按下 DeleteDealsAndOffersListPage 然后显示两个后退按钮。
答案 0 :(得分:1)
您似乎正在创建自己的“后退按钮”。 Xamarin会将其自己的后退按钮添加到您推送到导航堆栈的任何页面上,这是您看到的额外的后退按钮吗?如果是这样,则在执行推送之前,添加:
NavigationPage.SetHasBackButton(vm, false);