示例#1
0
        private EnumControl CreateEnumControl(EnumElement type)
        {
            var control = new EnumControl();

            control.DataContext = type;

            BindBlockControl(control);

            CreateEnumItems(control, type.Items);
            type.Items.CollectionChanged += (o, e) =>
            {
                var oldItems = e.OldItems ?? type.Items.PopClearedItems();
                if (oldItems != null)
                {
                    foreach (EnumItemElement oldItem in oldItems)
                    {
                        var property = control.Items.First(i => i.DataContext == oldItem);
                        control.Items.Remove(property);
                    }
                }
                if (e.NewItems != null)
                {
                    CreateEnumItems(control, e.NewItems);
                }
            };

            return(control);
        }
示例#2
0
        private EnumControl CreateEnumControl(EnumElement type)
        {
            var control = new EnumControl();
            control.DataContext = type;

            BindBlockControl(control);

            CreateEnumItems(control, type.Items);
            type.Items.CollectionChanged += (o, e) =>
            {
                var oldItems = e.OldItems ?? type.Items.PopClearedItems();
                if (oldItems != null)
                {
                    foreach (EnumItemElement oldItem in oldItems)
                    {
                        var property = control.Items.First(i => i.DataContext == oldItem);
                        control.Items.Remove(property);
                    }
                }
                if (e.NewItems != null)
                {
                    CreateEnumItems(control, e.NewItems);
                }
            };

            return control;
        }