[C++] Binding command to ListBox item select event
Posted: 28 Feb 2017, 08:25
How to bind to select event of listbox for item?
XAML View file:
C++ code behind:
XAML View file:
Code: Select all
<Listbox Selected="{Binding OnSelected}" ItemsSource="{Binding TheList2}" ItemTemplate="{StaticResource ListTemplate2}"/>
Code: Select all
class ViewModel_imports : public BaseComponent{
public:
ViewModel_imports() {
mListBoxItems = *new ObservableCollection<Item_model>;
cmd_on_selected = *new DelegateCommand(MakeDelegate(this, &ViewModel_imports::OnSelected));
}
Noesis::Ptr<ObservableCollection<Item_model> > mListBoxItems;
void OnSelected(BaseComponent* sender) {}
private:
Noesis::Ptr<DelegateCommand> cmd_on_selected ;
DelegateCommand* get_cmd_on_selected() const { return cmd_on_selected .GetPtr(); };
NS_IMPLEMENT_INLINE_REFLECTION(ViewModel_imports, BaseComponent) {
NsMeta<TypeId>("ViewModel2");
NsProp("TheList2", &ViewModel_imports::mListBoxItems);
NsProp("OnSelected", &ViewModel_imports::get_cmd_on_selected);
}
};