Beispiel #1
0
        private void CreateProperties(EntityTypeControl control, IEnumerable newItems)
        {
            foreach (PropertyElement newItem in newItems)
            {
                var property = new Property();
                property.DataContext = newItem;

                SetBinding(property, Property.PropertyNameProperty, "Name");
                SetBinding(property, Property.PropertyTypeProperty, "PropertyType");
                SetBinding(property, Property.LabelProperty, "Label");

                control.Items.Add(property);
            }
        }
Beispiel #2
0
        private EntityTypeControl CreateEntityTypeControl(EntityTypeElement type)
        {
            var control = new EntityTypeControl();
            control.DataContext = type;

            BindBlockControl(control);
            SetBinding(control, EntityTypeControl.HideDetailsProperty, "HideProperties");
            SetBinding(control, EntityTypeControl.IsAggtRootProperty, "IsAggtRoot");

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

            return control;
        }