简体   繁体   English

c#-Xamarin.Forms-更新条目文本不起作用

[英]c# - Xamarin.Forms - Updating Entry Text not working

I have an Entry like so:我有一个像这样的条目:

<Entry x:Name="Customer_Name" WidthRequest="200" Placeholder="Customer_Name" />

and I am trying to update it when this method gets called:当这个方法被调用时,我试图更新它:

public void Handle_OnScanResult(Result result)
{
     Customer_Name.Text = result.Trim();
}

But the text does not get updated....What am I doing wrong?但是文本没有更新....我做错了什么? Do I have to refresh the entry somehow?我必须以某种方式刷新条目吗?

you have to execute UI updates on the UI thread你必须在 UI 线程上执行 UI 更新

Device.BeginInvokeOnMainThread( () => {
  Customer_Name.Text = result.Trim();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM