Windows 通用应用程序 (XAML):无法使用给定的参数列表调用 textBlock->Text
Windows Universal app (XAML): textBlock->Text cannot be called with the given argument list
我正在尝试将 textBlock 设置为等于某些计算的结果,但由于某种原因我收到以下错误:"cannot be called with the given argument list" total is an int.
string Result;
ostringstream convert;
convert << total;
Result = convert.str();
textBlock->Text = Result;
该错误消息表示您将错误类型的参数传递给文本块的 Text
属性,它需要一个 Platform::String
,但您传递了一个 std::string. MSDN 页面 Strings(C++/CX) 包含有关字符串构造和转换的更多详细信息 - 在处理字符串。
下面是修改后的代码。请注意,我已将字符串更改为 wstring
(宽字符串,16 位 Unicode),以便我可以用它构造一个 Platform:String
。
wostringstream convert;
convert << total;
wstring str = convert.str();
String^ Result = ref new String(str.c_str());
tb1->Text = Result;
我正在尝试将 textBlock 设置为等于某些计算的结果,但由于某种原因我收到以下错误:"cannot be called with the given argument list" total is an int.
string Result;
ostringstream convert;
convert << total;
Result = convert.str();
textBlock->Text = Result;
该错误消息表示您将错误类型的参数传递给文本块的 Text
属性,它需要一个 Platform::String
,但您传递了一个 std::string. MSDN 页面 Strings(C++/CX) 包含有关字符串构造和转换的更多详细信息 - 在处理字符串。
下面是修改后的代码。请注意,我已将字符串更改为 wstring
(宽字符串,16 位 Unicode),以便我可以用它构造一个 Platform:String
。
wostringstream convert;
convert << total;
wstring str = convert.str();
String^ Result = ref new String(str.c_str());
tb1->Text = Result;