SimpleWindow
载入中...
搜索中...
未找到
ItemsControl.h
1#pragma once
2
3#include "Control.h"
4#include "IList.h"
5#include "INotifyCollectionChanged.h"
6
7namespace sw
8{
12 class ItemsControl : public Control
13 {
14 private:
18 IList *_itemsSource = nullptr;
19
23 struct {
25 IList *itemsSource = nullptr;
26
30 } _current;
31
32 public:
37
42
47
52
53 public:
58
59 protected:
64
69
73 virtual void OnSelectionChanged();
74
75 private:
81 void _CollectionChangedEventHandler(
83
84 protected:
91
98
104
108 virtual int GetSelectedIndex() = 0;
109
113 virtual void SetSelectedIndex(int index) = 0;
114 };
115}
控件
Definition Control.h:12
非模板列表接口,提供基于Variant的元素访问
Definition IList.h:11
支持集合变更通知的接口
Definition INotifyCollectionChanged.h:61
值转换器接口
Definition IValueConverter.h:14
表示可用于呈现一组项的控件
Definition ItemsControl.h:13
void UpdateCurrentItemsSource()
更新当前数据源状态并订阅新数据源的CollectionChanged事件(如果支持)
virtual void SetSelectedIndex(int index)=0
设置选中项索引
IList * GetCurrentItemsSource()
获取当前正在使用的数据源
virtual int GetSelectedIndex()=0
选中项的索引,当无选中项时为-1
IList * itemsSource
当前数据源的IList指针
Definition ItemsControl.h:25
const Property< int > SelectedIndex
选中项的索引,当无选中项时为-1
Definition ItemsControl.h:46
virtual IList * GetDefaultItemsSource()=0
获取默认数据源,当ItemsSource未设置时使用该数据源
const ReadOnlyProperty< Variant > SelectedItem
当前选中项的引用,当无选中项时返回空Variant对象
Definition ItemsControl.h:51
virtual void OnSelectionChanged()
选中项改变时调用该函数
INotifyCollectionChanged * notifyCollectionChanged
若当前数据源实现了INotifyCollectionChanged接口, 则该指针指向该接口以便订阅事件;否则为nullptr
Definition ItemsControl.h:29
const ReadOnlyProperty< int > ItemsCount
子项数量
Definition ItemsControl.h:41
ItemsControl()
构造函数
const Property< IList * > ItemsSource
数据源
Definition ItemsControl.h:36
virtual void OnCurrentItemsSourceCollectionChanged(const NotifyCollectionChangedEventArgs &args)=0
当数据源集合发生变更时调用该函数
virtual void OnCurrentItemsSourceChanged(IList *oldItemsSource, IList *newItemsSource)=0
当前数据源改变时调用该函数
集合变更事件参数类型
Definition INotifyCollectionChanged.h:33
SimpleWindow框架的顶级命名空间,所有公共类型、控件、枚举和工具函数均定义于此。
Definition Alignment.h:4