【问题标题】:c# - Xamarin.Forms - Updating Entry Text not workingc# - Xamarin.Forms - 更新条目文本不起作用
【发布时间】:2019-12-04 04:45:37
【问题描述】:

我有一个这样的条目:

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

我正在尝试在调用此方法时对其进行更新:

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

但是文本没有更新......我做错了什么?我必须以某种方式刷新条目吗?

【问题讨论】:

    标签: c# xamarin.forms


    【解决方案1】:

    你必须在 UI 线程上执行 UI 更新

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

    【讨论】:

    • 完美!有用!谢谢!你今天真的帮了我,杰森,谢谢。
    猜你喜欢
    • 2021-08-06
    • 1970-01-01
    • 2023-03-19
    • 2020-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    相关资源
    最近更新 更多