Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Shell在forms app中的新XAMRA文件中的行为不符合预期_C#_Xaml_Xamarin.forms_Xamarin.forms.shell - Fatal编程技术网

C# Shell在forms app中的新XAMRA文件中的行为不符合预期

C# Shell在forms app中的新XAMRA文件中的行为不符合预期,c#,xaml,xamarin.forms,xamarin.forms.shell,C#,Xaml,Xamarin.forms,Xamarin.forms.shell,为什么当我使用时会松开外壳菜单项,即汉堡包菜单 private async void btnAddBill_Clicked(object sender, EventArgs e) { await Shell.Current.GoToAsync("NewBillItemPage"); } 你会在这个屏幕上看到我有菜单 但是,一旦我调用上面的命令,当我单击add时,它会松开菜单;当我单击back按钮时,它会恢复菜单,但它不会给我留下 因为我也用这个移回到了列表

为什么当我使用时会松开外壳菜单项,即汉堡包菜单

private async void btnAddBill_Clicked(object sender, EventArgs e)
{
        await Shell.Current.GoToAsync("NewBillItemPage");
}
你会在这个屏幕上看到我有菜单

但是,一旦我调用上面的命令,当我单击add时,它会松开菜单;当我单击back按钮时,它会恢复菜单,但它不会给我留下

因为我也用这个移回到了列表页面

private async void btnCancel_Clicked(object sender, EventArgs e)
{
        await Shell.Current.GoToAsync("BillsPage");
}

如何在整个导航体验中保留菜单似乎shell在5.0.0.2012中有点破损

只有在AppShell中更改的代码是

<FlyoutItem Title="Bills" Icon="icon_feed.png">
    <ShellContent Route="Bills" ContentTemplate="{DataTemplate local:BillsPage}" />
</FlyoutItem>
<FlyoutItem Title="About" Icon="icon_about.png">
    <ShellContent Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
</FlyoutItem>
编辑3

“新建账单项目”页面位于账单主列表页面上的工具栏项目之外

 <ContentPage.ToolbarItems>
    <ToolbarItem Text="Add" Clicked="btnAddBill_Clicked"  x:Name="btnAddBill" />
    <ToolbarItem Order="Primary"  IconImageSource="" x:Name="btnclearTestData" Clicked="btnclearTestData_Clicked" />
</ContentPage.ToolbarItems>

上面的代码是从添加工具栏的btnAddBill_Clicked事件调用的

这是NewBillTempage xaml的代码

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="BillManager.Views.NewBillItemPage"
         Shell.PresentationMode="ModalAnimated"
         Title="New Item"
         xmlns:combobox="clr-namespace:Syncfusion.XForms.ComboBox;assembly=Syncfusion.SfComboBox.XForms"
         xmlns:syncfusion="clr-namespace:Syncfusion.XForms.Pickers;assembly=Syncfusion.SfPicker.XForms"

         xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
         ios:Page.UseSafeArea="true">

<ContentPage.Content>
    <StackLayout Spacing="3" Padding="15">
        
        
        <Entry x:Name="txtDescription" FontSize="Medium"  Placeholder="Bill Name"/>
        <Grid RowDefinitions="30, 35">
            <DatePicker x:Name="billStartDate" 
            Grid.Row="1"
            Margin="0, -35, 0, 0"
            VerticalOptions="Center"
            HorizontalOptions="Start"
            WidthRequest="200"
            Format="dd-MMM-yyyy"
            TextTransform="Uppercase"
            FontSize="Body" />
            <Label Text="Start Date" 
        Grid.Row="0"
        Margin="12, 10, 0, 0"
 />
        </Grid>

        <Grid RowDefinitions="30, 35">
            <DatePicker x:Name="billEndDate" 
            Grid.Row="1"
            Margin="0, -35, 0, 0"
            VerticalOptions="Center"
            HorizontalOptions="Start"
            WidthRequest="200"
            Format="dd-MMM-yyyy"
            TextTransform="Uppercase"
            FontSize="Body" />
            <Label Text="End Date" 
        Grid.Row="0"
        Margin="12, 10, 0, 0"
         />
        </Grid>


        <Label Text="Repeat Bill:" 
       
         />

        <combobox:SfComboBox x:Name="cboOccourances" HeightRequest="40" DataSource="{Binding EmployeeCollection}"  DisplayMemberPath="Description" SelectedValuePath="Type">
        </combobox:SfComboBox>



        <Editor AutoSize="TextChanges" FontSize="Medium" Margin="0" />
        <StackLayout Orientation="Horizontal">
            <Button Text="Cancel"  x:Name="btnCancel" Clicked="btnCancel_Clicked" HorizontalOptions="FillAndExpand"></Button>
            <Button Text="Save" x:Name="btnSave" Clicked="btnSave_Clicked" HorizontalOptions="FillAndExpand"></Button>
        </StackLayout>
    </StackLayout>
</ContentPage.Content>

现在代码隐藏了

public partial class NewBillItemPage : ContentPage
 {
    public Bills Item { get; set; }
    private BillManagerDB db;
    public NewBillItemPage()
    {
        InitializeComponent();
        BindingContext = new BillDetailViewModel();
        db = new BillManagerDB();
        Setup();
    }

    private async void btnSave_Clicked(object sender, EventArgs e)
    {
        Bills bill = new Bills();
        bill.Description = txtDescription.Text;
        bill.Startdate = billStartDate.Date;
        bill.EndDate = billEndDate.Date;
        bill.isActive = true;
        bill.isDeleted = false;
        await db.SaveBillItem(bill);
        await DisplayAlert("Bill Saved", "Your build details have been saved.", "OK");
        await Shell.Current.GoToAsync("BillsPage");
    }

    private async  void btnCancel_Clicked(object sender, EventArgs e)
    {
        await Shell.Current.GoToAsync("BillsPage");
    }
    public void Setup()
    {

        List<BillOccuranceTypeViewModel> billOccuranceType = new List<BillOccuranceTypeViewModel>();
        billOccuranceType = new List<BillOccuranceTypeViewModel>()
        {
              new BillOccuranceTypeViewModel {Description="Once",Type=1},
              new BillOccuranceTypeViewModel { Description="Never",Type=2},
              new BillOccuranceTypeViewModel { Description="Weekly",Type=3},
              new BillOccuranceTypeViewModel { Description="Monthly",Type=4},
              new BillOccuranceTypeViewModel { Description="Yearly",Type=5},
              new BillOccuranceTypeViewModel { Description="Quartley",Type=6},

        };
        cboOccourances.DataSource = billOccuranceType;
    }     
}
}
public分部类NewBillItemPage:ContentPage
{
公共票据项目{get;set;}
私人BillManagerDB;
公共图书馆()
{
初始化组件();
BindingContext=新的BillDetailViewModel();
db=新的BillManagerDB();
设置();
}
私有异步无效btnSave_已单击(对象发送方,事件参数e)
{
账单=新账单();
bill.Description=txtDescription.Text;
bill.Startdate=billStartDate.Date;
bill.EndDate=billEndDate.Date;
bill.isActive=true;
bill.isDeleted=false;
等待db.SaveBillItem(账单);
等待DisplayAlert(“账单已保存”,“构建详细信息已保存”,“确定”);
等待Shell.Current.GoToAsync(“BillsPage”);
}
私有异步无效btnCancel_已单击(对象发送方,事件参数e)
{
等待Shell.Current.GoToAsync(“BillsPage”);
}
公共作废设置()
{
List billOccuranceType=新列表();
billOccuranceType=新列表()
{
新BillOccuranceTypeViewModel{Description=“Once”,Type=1},
新BillOccuranceTypeViewModel{Description=“Never”,Type=2},
新BillOccuranceTypeViewModel{Description=“Weekly”,Type=3},
新BillOccuranceTypeViewModel{Description=“Monthly”,Type=4},
新BillOccuranceTypeViewModel{Description=“Yearly”,Type=5},
新BillOccuranceTypeViewModel{Description=“Quartley”,Type=6},
};
cbooccurances.DataSource=billOccuranceType;
}     
}
}

对于其他陷入这一困境的人来说,答案很简单,就是双点标记

await Shell.Current.GoToAsync("..");

一位所谓的微软金融时报工作人员的上述回答是可笑的,根本不是正确的方法。

您从哪个页面呼叫
wait Shell.Current.GoToAsync(“NewBillItemPage”)?您的账单页似乎影响了某些Shell属性,您能否共享该页的相关代码?或者用另一个空白或不同内容的页面进行测试?你能澄清你的第一句话吗?NewBillTempage和BillsPage之间的关系是什么?它的母版页是一个列表,新的母版页正在添加一个项目@CfunPlease请参见编辑3
await Shell.Current.GoToAsync("..");