gpt4 book ai didi

c# - 当我使用 x :bind in uwp: invalid binding path err 时出错

转载 作者:行者123 更新时间:2023-11-30 21:28:35 24 4
gpt4 key购买 nike

我尝试使用 x:bind 函数来显示使用 String.Concat() 连接两个字符串的字符串。我按照本网站的说明进行操作:https://learn.microsoft.com/en-us/windows/uwp/data-binding/function-bindings

由于是第一次在Stack Overflow上提问,如果我的提问方式有误,请指出。谢谢(≧∀≦)ゞ

我尝试在另一个命名空间中创建的函数中使用 System.Contact(),它看起来不错。

xmlns:sys="using:System"
xmlns:local="using:uwpppp.Scenes.ReciteF">

...

<TextBlock Text="{x:Bind sys:String.Concat('hello','123')}"/><!--not good-->

<TextBlock Text="{x:Bind local:Showdetail.GetString('hello','hello2')}"/><!--good-->
public static String GetString(string a, string b)
{
return String.Concat(a, b);
}

无效的绑定(bind)路径 'sys:String.Concat('hello','123')' : 函数参数 '1' 无效或不匹配

最佳答案

根据documentation ,我认为问题出在这一点上:

Overloading is based on the number of arguments, not type, and it will try to match to the first overload with that many arguments

String.Concat 有许多不同的重载,x:Bind 机制最有可能首先找到 (object,object) 重载,然后导致您看到的错误:

Invalid or missmatched parameter at position '1'.

对于您的自定义方法,您只有一个重载,因此它可以清楚地使用 (string, string) 参数。

关于c# - 当我使用 x :bind in uwp: invalid binding path err 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56344751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com