android - Binding 的值没有显示在 ios 中,但在 android 上正常工作
问题描述
当显示具有两个数据绑定的页面时,值会在 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>
ios版本中是否缺少一些额外的配置?
编辑:这是应用程序背后的一些代码:
Payment.cs(用于存储所需数据的类):
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;
}
}
}
ConfirmTopUp.xaml.cs(视图背后的代码):
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());
}
}
}
TopUpOptions.xaml.cs(从中传递数据的视图):
var paymentDetails = new Payment
{
Denominations = topUpValue.ToString(),
MeterNumber = meter.MeterNumber
};
var toPayment = new PaymentPage();
toPayment.BindingContext = paymentDetails;
await Navigation.PushAsync(toPayment);
解决方案
推荐阅读
- javascript - 将不同的 Bootstrap-Scrollbars 添加到不同的 Div-Container
- azure - Azure Function App 通过应用程序设置使用最新版本的 Key Vault Secret
- sas - sas企业指南中的数据步骤问题
- javascript - 如何在 Angular 中加载图像?
- homebrew - 如何在具有普通管理员用户的 Mac 上安装 brew?
- mysql - MySQL GROUP_CONCAT 和 JOIN
- file-monitoring - 文件和文件夹监控效率
- javascript - 反应 axios 状态一开始不会设置
- laravel - Laravel 7 圣所注销
- swift5 - CoreData 和 Struct 之间的自定义编码/解码