I'm writing a windows universal app (store app) in C++ and XAML, and I made a listview which I want to add items to. This works perfectly fine when hard-coding the items, but once I want to add them via a loop, this doesn't work anymore. And I get the error
cannot convert argument 1 from 'const char *' to 'Platform::Object ^'
Could anyone tell me what I'm doing wrong? Thank you
My code:
/* This works */
myListView->Items->Append("Hello, world!");
/* This doesn't work */
const char* strarray[] = { "Hello", "World", "Awesome" };
for (int i = 0; i < sizeof(strarray); i++) {
myListView->Items->Append(strarray[i]);
}
You are using a basic datatype for your string array
const char* strarray[]
So maybe the function xxx->Items->Append()
needs to receive a managed datatype which would be the following for example:
array<String^>^ strarray = { "Hello", "World", "Awesome" };