Windows 通用应用 (XAML):不能使用给定的参数列表调用文本块>文本
Windows Universal app (XAML): textBlock->Text cannot be called with the given argument list
我试图将textBlock设置为等于某些计算的结果,但由于某种原因,我得到了以下错误:"无法使用给定的参数列表调用"total是int。
string Result;
ostringstream convert;
convert << total;
Result = convert.str();
textBlock->Text = Result;
错误消息表示您将错误类型的参数传递给textBlock的Text
属性,该属性需要Platform::String
,但您传递了std::字符串。MSDN页面Strings(C++/CX)包含有关字符串构造和转换的更多详细信息,在处理字符串时,还需要注意ANSI和UNICODE。
以下是修改后的代码。注意,我已经将字符串更改为wstring
(宽字符串,16位Unicode),这样我就可以用它构造一个Platform:String
wostringstream convert;
convert << total;
wstring str = convert.str();
String^ Result = ref new String(str.c_str());
tb1->Text = Result;
相关文章:
- 什么时候调用组成单元对象的析构函数
- Doxygen - 如何在不生成图形的情况下生成文本调用关系结果
- 调用 cout 时如何在结构中输出常量文本?
- 如何调用继承的重载运算符<<并在派生类的输出中添加更多文本?
- 是否可以在运行时调用用于选择要调用的用户定义文本的逻辑?
- 在左值上调用用户定义的文本
- 为什么插槽函数即使成功调用也无法插入文本
- FindResource 调用返回 RCDATA 类型的文本文件的 NULL
- 我应该如何在文本RPG中调用播放器咒语
- 写入系统调用 Unix 不会从 Argv 写入所有文本
- 功能调用,该函数从文本文件-C 检查输入正确性
- 使用读取系统调用C++输出文本
- Windows 通用应用 (XAML):不能使用给定的参数列表调用文本块>文本
- 将用户定义的文本与方法调用相结合
- 发送 recv 调用时带有 C++ 字符串的垃圾文本
- 日志(PCTSTR 格式,..)和日志(PCTSTR 文本):错误 C2668 对重载函数的不明确调用
- 将指向字符串文本的指针返回给调用方是否安全
- 调用非函数,文本也不显示
- 更新Qlabel文档矩形,该矩形调用的标签不是文本标签.为什么
- 调用从文本文件解析参数表的函数的方法