C++ ItemControl
Hi, how can I add items to a ItemControl or any control derived from it in C++? I followed this C# WFP documentation: https://docs.microsoft.com/en-us/dotnet ... esktop-6.0
and also tried to only use the SetItemsSource() function
But none of them worked...
Code: Select all
Ptr<ItemsControl> pItemsControl = *new ItemsControl();
Ptr<Binding> pBinding = *new Binding();
Ptr<BaseComponent> pBoxed = Boxing::Box("FirstItem");
pBinding->SetSource(pBoxed);
pItemsControl->SetBinding(pItemsControl->ItemsSourceProperty, pBinding);
Code: Select all
Ptr<ItemsControl> pItemsControl = *new ItemsControl();
Ptr<Binding> pBinding = *new Binding();
Ptr<BaseComponent> pBoxed = Boxing::Box("FirstItem");
pItemsControl->SetItemsSource(pBoxed);
-
sfernandez
Site Admin
- Posts: 2997
- Joined:
Re: C++ ItemControl
An ItemsControl can be populated with items in 2 ways:
- By adding items to its Items collection
Code: Select all
itemsControl->GetItems()->Add(Boxing::Box("First")); itemsControl->GetItems()->Add(Boxing::Box("Second")); itemsControl->GetItems()->Add(Boxing::Box("Third"));
- By setting a collection as its ItemsSource
Code: Select all
Ptr<ObservableCollection<BaseComponent>> items = MakePtr<ObservableCollection<BaseComponent>>(); items->Add(Boxing::Box("First")); items->Add(Boxing::Box("Second")); items->Add(Boxing::Box("Third")); itemsControl->SetItemsSource(items);
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 22 guests