Esempio n. 1
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            var attributeConfigurationButton = (AttributeConfigurationButton)element;

            this.buttons.Add(attributeConfigurationButton);
            attributeConfigurationButton.MouseLeftButtonDown += this.AttributeConfigurationButton_MouseLeftButtonDown;

            if (attributeConfigurationButton != null && item is AttributeConfigurationEditorSection)
            {
                var attributeConfigurationEditorSection = (AttributeConfigurationEditorSection)item;
                base.PrepareContainerForItemOverride(attributeConfigurationButton, attributeConfigurationEditorSection);

                Binding sectionHeaderBinding = new Binding("Header")
                {
                    Source = attributeConfigurationEditorSection
                };
                attributeConfigurationButton.SetBinding(AttributeConfigurationButton.ContentProperty, sectionHeaderBinding);

                Binding sectionHeaderImageBinding = new Binding("HeaderImage")
                {
                    Source = attributeConfigurationEditorSection
                };
                attributeConfigurationButton.SetBinding(AttributeConfigurationButton.HeaderProperty, sectionHeaderImageBinding);

                foreach (var attributeConfigurationProperty in attributeConfigurationEditorSection.Properties)
                {
                    var dataGridColumn = new ExtendedDataGridColumn()
                    {
                        DataGrid    = this.dataGrid,
                        Header      = attributeConfigurationProperty.Header,
                        BindingPath = attributeConfigurationProperty.BindingPath,
                        SupportedValuesDisplayMemberPath = attributeConfigurationProperty.SupportedValuesDisplayMemberPath,
                        SupportedValuesValuePath         = attributeConfigurationProperty.SupportedValuesValuePath
#if (!SILVERLIGHT)
                        ,
                        CanUserSort    = true,
                        SortMemberPath = attributeConfigurationProperty.BindingPath
#endif
                    };
                    var supportedValuesbinding = new Binding("SupportedValues")
                    {
                        Source = attributeConfigurationProperty, Mode = BindingMode.TwoWay
                    };
                    BindingOperations.SetBinding(dataGridColumn, ExtendedDataGridColumn.SupportedValuesProperty, supportedValuesbinding);

                    if (!attributeConfigurationProperty.ShowInAllSections)
                    {
                        var visibilityBinding = new Binding("IsSelected");
                        visibilityBinding.Converter = new BoolToVisibilityConverter();
                        visibilityBinding.Source    = attributeConfigurationButton;
#if (!SILVERLIGHT)
                        BindingOperations.SetBinding(dataGridColumn, DataGridColumn.VisibilityProperty, visibilityBinding);
#else
                        BindingOperations.SetBinding(dataGridColumn, AttributeConfigurationEditor.ColumnVisibilityProperty, visibilityBinding);
#endif
                    }
                    dataGrid.Columns.Add(dataGridColumn);
                }
            }
            this.UpdateButtons();
        }
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)      {

            var attributeConfigurationButton = (AttributeConfigurationButton)element;
            this.buttons.Add(attributeConfigurationButton);
            attributeConfigurationButton.MouseLeftButtonDown += this.AttributeConfigurationButton_MouseLeftButtonDown;

            if (attributeConfigurationButton != null && item is AttributeConfigurationEditorSection)
            {
                var attributeConfigurationEditorSection = (AttributeConfigurationEditorSection)item;
                base.PrepareContainerForItemOverride(attributeConfigurationButton, attributeConfigurationEditorSection);

                Binding sectionHeaderBinding = new Binding("Header") { Source = attributeConfigurationEditorSection };
                attributeConfigurationButton.SetBinding(AttributeConfigurationButton.ContentProperty, sectionHeaderBinding);

                Binding sectionHeaderImageBinding = new Binding("HeaderImage") { Source = attributeConfigurationEditorSection };
                attributeConfigurationButton.SetBinding(AttributeConfigurationButton.HeaderProperty, sectionHeaderImageBinding);

                foreach (var attributeConfigurationProperty in attributeConfigurationEditorSection.Properties)
                {
                    var dataGridColumn = new ExtendedDataGridColumn() 
                    {
                        DataGrid = this.dataGrid,
                        Header = attributeConfigurationProperty.Header,
                        BindingPath = attributeConfigurationProperty.BindingPath,
                        SupportedValuesDisplayMemberPath = attributeConfigurationProperty.SupportedValuesDisplayMemberPath,
                        SupportedValuesValuePath = attributeConfigurationProperty.SupportedValuesValuePath
#if(!SILVERLIGHT)
                        ,
                        CanUserSort = true,
                        SortMemberPath = attributeConfigurationProperty.BindingPath
#endif
                    };
                    var supportedValuesbinding = new Binding("SupportedValues") { Source = attributeConfigurationProperty, Mode = BindingMode.TwoWay };
                    BindingOperations.SetBinding(dataGridColumn, ExtendedDataGridColumn.SupportedValuesProperty, supportedValuesbinding);

                    if (!attributeConfigurationProperty.ShowInAllSections)
                    {                     
                        var visibilityBinding = new Binding("IsSelected");
                        visibilityBinding.Converter = new BoolToVisibilityConverter();
                        visibilityBinding.Source = attributeConfigurationButton;
#if(!SILVERLIGHT)   
                        BindingOperations.SetBinding(dataGridColumn, DataGridColumn.VisibilityProperty, visibilityBinding);
#else
                        BindingOperations.SetBinding(dataGridColumn, AttributeConfigurationEditor.ColumnVisibilityProperty, visibilityBinding);
#endif
                    }
                    dataGrid.Columns.Add(dataGridColumn);
                }
            }           
            this.UpdateButtons();
        }