Ejemplo n.º 1
0
        /// <summary>
        /// 生成下拉框控件
        /// </summary>
        /// <returns></returns>
        protected override FrameworkElement CreateEditingElement()
        {
            var refVI       = this.Meta.SelectionViewMeta;
            var refTypeMeta = refVI.RefTypeDefaultView.AsWPFView();

            var title = refTypeMeta.TitleProperty;

            if (title == null)
            {
                throw new InvalidProgramException(string.Format("{0} 没有设置代表属性,生成下拉控件时出错。", refTypeMeta.Name));
            }

            //创建 ComboListControl : 使用下拉控件显示
            this._cmbList = new ComboListControl
            {
                RefViewMeta      = refTypeMeta,
                IsMultiSelection = this.IsMultiSelection,
                Name             = this.Meta.Name,
            };
            this._cmbList.InnerListView.CheckItemsChanged += On_ListView_CurrentObjectChanged;
            this._cmbList.ListViewSelectionChanged        += On_ListView_CurrentObjectChanged;
            this._cmbList.DropDownOpened += On_ComboList_DropDownOpened;

            this.AddReadOnlyComponent(this._cmbList, ComboBox.IsEnabledProperty, false);

            this.ResetBinding(this._cmbList);

            this.SetAutomationElement(this._cmbList);

            return(this._cmbList);
        }
Ejemplo n.º 2
0
        public static ComboListControl CreateComboListControl(ListLogicalView view)
        {
            var titleProperty = view.Meta.TitleProperty;
            if (titleProperty == null) throw new InvalidProgramException(view.EntityType.Name + "类没有设置 Title 属性。");

            var ddl = new ComboListControl
            {
                InnerListView = view,
                Name = "下拉列表",
                VerticalAlignment = VerticalAlignment.Center,
                MinWidth = 150,
            };

            ddl.DataContext = view;
            ddl.SetBinding(ComboListControl.TextProperty, "CurrentObject." + titleProperty);

            //当 View 发生 Refreshed 事件时,很可能表示有底层数据改变了,但是没有级联通知到界面上,
            //所以当 View 的控件被 Refresh 后,这个下拉框也需要主动进行刷新。
            view.Refreshed += (o, e) =>
            {
                ddl.GetBindingExpression(ComboListControl.TextProperty).UpdateTarget();
            };

            return ddl;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 生成下拉框控件
        /// </summary>
        /// <returns></returns>
        protected override FrameworkElement CreateEditingElement()
        {
            var refVI = this.Meta.SelectionViewMeta;
            var refTypeMeta = refVI.RefTypeDefaultView.AsWPFView();

            var title = refTypeMeta.TitleProperty;
            if (title == null) throw new InvalidProgramException(string.Format("{0} 没有设置代表属性,生成下拉控件时出错。", refTypeMeta.Name));

            //创建 ComboListControl : 使用下拉控件显示
            this._cmbList = new ComboListControl
            {
                RefViewMeta = refTypeMeta,
                IsMultiSelection = this.IsMultiSelection,
                Name = this.Meta.Name,
            };
            this._cmbList.InnerListView.CheckItemsChanged += On_ListView_CurrentObjectChanged;
            this._cmbList.ListViewSelectionChanged += On_ListView_CurrentObjectChanged;
            this._cmbList.DropDownOpened += On_ComboList_DropDownOpened;

            this.AddReadOnlyComponent(this._cmbList, ComboBox.IsEnabledProperty, false);

            this.ResetBinding(this._cmbList);

            this.SetAutomationElement(this._cmbList);

            return this._cmbList;
        }