ich eine Klasse zu implementieren versucht, die here als ItemSource
für ListView
folgende Microsoft-Dokumentation gesetzt werden kann heißt IObservableVector<T>
Umsetzung aber wie immer, Dokumentation funktioniert nie und es gibt keine C++ Beispielcode zu beginnen. Der Inhalt meiner XAML für Mainpage ist nurrichtig implementieren ItemSource für Listview
<ListView x:Name="TestListView"/>
und der Quellcode
public ref class MyStringSrc sealed : Windows::Foundation::Collections::IObservableVector<Platform::String^>
{
public:
// Inherited via IVector
virtual Windows::Foundation::Collections::IIterator<Platform::String ^>^First();
// Inherited via IObservableVector
virtual property unsigned int Size
{
unsigned int get()
{
return _size;
}
}
virtual Platform::String^GetAt(unsigned int index);
virtual Windows::Foundation::Collections::IVectorView<Platform::String ^>^GetView();
virtual bool IndexOf(Platform::String ^value, unsigned int *index);
virtual void SetAt(unsigned int index, Platform::String ^value);
virtual void InsertAt(unsigned int index, Platform::String ^value);
virtual void RemoveAt(unsigned int index);
virtual void Append(Platform::String ^value);
virtual void RemoveAtEnd();
virtual void Clear();
virtual unsigned int GetMany(unsigned int startIndex, Platform::WriteOnlyArray<Platform::String ^, 1U> ^items);
virtual void ReplaceAll(const Platform::Array<Platform::String ^, 1U> ^items);
virtual event Windows::Foundation::Collections::VectorChangedEventHandler<Platform::String ^>^VectorChanged;
private:
unsigned int _size = 1000;
};
public ref class MainPage sealed
{
public:
MainPage();
};
MainPage::MainPage()
{
InitializeComponent();
TestListView->ItemsSource = ref new MyStringSrc();
}
Windows::Foundation::Collections::IIterator<Platform::String ^>^MyStringSrc::First()
{
throw ref new Platform::NotImplementedException();
// TODO: insert return statement here
}
Platform::String^MyStringSrc::GetAt(unsigned int index)
{
throw ref new Platform::NotImplementedException();
// TODO: insert return statement here
}
Windows::Foundation::Collections::IVectorView<Platform::String ^>^MyStringSrc::GetView()
{
throw ref new Platform::NotImplementedException();
// TODO: insert return statement here
}
bool MyStringSrc::IndexOf(Platform::String ^value, unsigned int *index)
{
return false;
}
void MyStringSrc::SetAt(unsigned int index, Platform::String ^value)
{
throw ref new Platform::NotImplementedException();
}
void MyStringSrc::InsertAt(unsigned int index, Platform::String ^value)
{
throw ref new Platform::NotImplementedException();
}
void MyStringSrc::RemoveAt(unsigned int index)
{
throw ref new Platform::NotImplementedException();
}
void MyStringSrc::Append(Platform::String ^value)
{
throw ref new Platform::NotImplementedException();
}
void MyStringSrc::RemoveAtEnd()
{
throw ref new Platform::NotImplementedException();
}
void MyStringSrc::Clear()
{
throw ref new Platform::NotImplementedException();
}
unsigned int MyStringSrc::GetMany(unsigned int startIndex, Platform::WriteOnlyArray<Platform::String ^, 1U> ^items)
{
return 0;
}
void MyStringSrc::ReplaceAll(const Platform::Array<Platform::String ^, 1U> ^items)
{
throw ref new Platform::NotImplementedException();
}
Wenn die App läuft, habe ich immer
Microsoft C++ Ausnahme: Plattform :: InvalidArgumentException^auf Speicherplatz 0x02E2DA80. HRESULT: 0x80070057 Der Parameter ist falsch. WinRT-Information: Der Parameter ist falsch.
direkt an der Linie, wo ich
TestListView->ItemsSource = ref new MyStringSrc();
gesetzt Gibt es eine Beispielimplementierung ich folgen kann?
Benötigen Sie speziell eine benutzerdefinierte IObservableVector-Klasse, anstatt etwas wie [Vector] (https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh441570.aspx) zu verwenden? –
@DecadeMoon Ich weiß es eigentlich nicht. Ich versuche, inkrementelles Laden durchzuführen, wie in dem Artikel, der vorschlägt, "IObservableVector" zu implementieren. –