首页 > 解决方案 > 无法获取 SfMaskedEdit 和 SfNumericTextBox 的值

问题描述

我无法获得动态添加的 SfMaskedEdit 和 SfNumericTextBox 的值。

SfNumericTextBox num = new SfNumericTextBox();
num.StyleId = q.Id + "-x";
num.MaximumNumberDecimalDigits = 0;
if(!string.IsNullOrWhiteSpace(q.Suffix))
    num.FormatString = q.Suffix;
//num.MaximumNumberDecimalDigits = 99999;
num.Watermark = "Enter numbers";

num.Unfocused += Num_Unfocused;
num.TextColor = Color.FromHex("303030");
testContainer.Children.Add(num);


    private void Num_Unfocused(object sender, Xamarin.Forms.FocusEventArgs e)
    {
        SfNumericTextBox obj = (SfNumericTextBox)sender;
        keyValues.AddOrUpdate(id, Convert.ToString(obj.Value), (key, oldValue) => Convert.ToString(obj.Value));//obj.Value is always null
    }

标签: xamarinxamarin.formssyncfusion

解决方案


我们在 Unfocused 事件中检查了 SfNumericTextBox 的 Value 属性,其中输入的值在所有平台(Android、iOS 和 UWP)中都正确可用。我们担心,我们最终无法重现该问题。我们已附上测试样本,请从以下位置下载。

示例:https ://www.syncfusion.com/downloads/support/directtrac/general/ze/NumericTxtBox1870210506

此外,我们想建议您,您可以使用 ValueChanged 事件从事件参数 (ValueEventArgs(e.Value)) 中获取 SfNumericTextBox 的值。请检查随附的样本,如果您遇到任何问题,请告诉我们。

请参阅以下文档链接以了解有关 ValueChanged 事件的更多信息。 https://help.syncfusion.com/xamarin/sfnumerictextbox/events-and-interactivity#valuechanged

问候,雷切尔。


推荐阅读