c++-cx

List collection in C++/CX


I'm trying to find a way to create a collection (List) with C++/CX, I tried this code but the List type isn't recognized:

#pragma once

using namespace AdDuplex::Common::Models;
using namespace AdDuplex::Banners::Core;
using namespace AdDuplex::Banners::Models;

using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;

using namespace Platform;
using namespace Platform::Collections;
using namespace Windows::Foundation::Collections;

//using namespace System::Collections::Generic; //This line generate an error if uncommented

ref class BannerManager
{
public:
    static void Initialise(Grid^);

private:
    static List<AdDuplex::AdControl>^ _controls; //List isn't recognized here
    static Grid^ _grid;
};

Any idea how to use List with C++/CX or another collection type supporting adding/removing elements?


Solution

  • C++/CX is not C++/CLI so you can't access .NET classes that are in the system namespace. Instead of list use Platform::Collections::Vector.