Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.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
绑定值未在ios中显示,但在android上正常工作_Android_Ios_Xamarin.forms - Fatal编程技术网

绑定值未在ios中显示,但在android上正常工作

绑定值未在ios中显示,但在android上正常工作,android,ios,xamarin.forms,Android,Ios,Xamarin.forms,当显示带有两个数据绑定的页面时,这些值在android中完美显示,如下所示: 但在ios上运行时,仅显示其中一个值: 页面的xaml代码如下所示: <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class=&qu

当显示带有两个数据绑定的页面时,这些值在android中完美显示,如下所示:

但在ios上运行时,仅显示其中一个值:

页面的xaml代码如下所示:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MultiTest.PaymentPage"
             Title="Confirm Payment">
    <ContentPage.Content>
        <StackLayout Margin ="20" Spacing="5">
            <Label Text="Top Up Value: "
                   VerticalTextAlignment="Center"
               />
            <Label Text="{Binding Denominations}"
                   VerticalTextAlignment="Center"
                
                   x:Name="TopUpValue"/>
            <Label Text="Meter Number:"
                   VerticalTextAlignment="Center"
                />
            <Label Text="{Binding MeterNumber}"  VerticalTextAlignment="Center"
              
                   x:Name="CreditCardDetails"/>
            <Button Text="To Payment" Clicked="ToConfirmPayment"/>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
ConfirmTopUp.xaml.cs(视图的代码):

TopUpOptions.xaml.cs(数据从中传递的视图):


你能和我们分享一下代码背后的代码吗?添加了一些代码,希望这能让它更清晰一些。只需补充:屏幕截图中的iOS模拟器运行的是iOS 14.1。如果您将面额=topUpValue.ToString()更改为面额=“测试”,是否会出现问题?是的,在清洁和构建解决方案后刚刚测试,问题仍然会出现。在我这方面效果良好。如果您不使用绑定而直接在xaml中提供字符串,这是否有效?
using System;
using System.Collections.Generic;
using System.Text;

namespace MultiTest.Models
{
    public class Payment
    {
        public string Denominations { get; set; }
        public string MeterNumber { get; set; }

        public override string ToString()
        {
            return MeterNumber;
        }



    }
}
using System.Text;
using System.Threading.Tasks;
using MultiTest.Models;
using MultiTest.ViewModel;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace MultiTest
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class PaymentPage : ContentPage
    {

       //public Payment topUp;
        public PaymentPage()
        {
            InitializeComponent();
            BindingContext = new Payment();
        }

        async void ToConfirmPayment(object sender, EventArgs args)
        {
            await Navigation.PushAsync(new PaymentConfirmation());
        }
    }
}
  var paymentDetails = new Payment
                        {
                            Denominations = topUpValue.ToString(),
                            MeterNumber = meter.MeterNumber
                        };

                        var toPayment = new PaymentPage();
                        toPayment.BindingContext = paymentDetails;
                        await Navigation.PushAsync(toPayment);