Beispiel #1
0
 private void SyncProperties(FrameworkElement e)
 {
     DataGridHelper.SyncColumnProperty(this, e, TextElement.FontFamilyProperty, FontFamilyProperty);
     DataGridHelper.SyncColumnProperty(this, e, TextElement.FontSizeProperty, FontSizeProperty);
     DataGridHelper.SyncColumnProperty(this, e, TextElement.FontStyleProperty, FontStyleProperty);
     DataGridHelper.SyncColumnProperty(this, e, TextElement.FontWeightProperty, FontWeightProperty);
     DataGridHelper.SyncColumnProperty(this, e, TextElement.ForegroundProperty, ForegroundProperty);
 }
        private void ApplyColumnProperties(PactComboBox comboBox)
        {
            ApplyBinding(SelectedItemBinding, comboBox, PactComboBox.SelectedItemProperty);
            ApplyBinding(SelectedValueBinding, comboBox, PactComboBox.SelectedValueProperty);
            ApplyBinding(TextBinding, comboBox, PactComboBox.TextProperty);

            DataGridHelper.SyncColumnProperty(this, comboBox, PactComboBox.SelectedValuePathProperty, SelectedValuePathProperty);
            DataGridHelper.SyncColumnProperty(this, comboBox, PactComboBox.DisplayMemberPathProperty, DisplayMemberPathProperty);
            DataGridHelper.SyncColumnProperty(this, comboBox, PactComboBox.ItemsSourceProperty, ItemsSourceProperty);
        }
        protected internal override void RefreshCellContent(FrameworkElement element, string propertyName)
        {
            DataGridCell cell = element as DataGridCell;

            if (cell != null)
            {
                bool isCellEditing = cell.IsEditing;
                if ((string.Compare(propertyName, "ElementStyle", StringComparison.Ordinal) == 0 && !isCellEditing) ||
                    (string.Compare(propertyName, "EditingElementStyle", StringComparison.Ordinal) == 0 && isCellEditing))
                {
                    cell.BuildVisualTree();
                }
                else
                {
                    ComboBox comboBox = cell.Content as ComboBox;
                    switch (propertyName)
                    {
                    case "SelectedItemBinding":
                        ApplyBinding(SelectedItemBinding, comboBox, ComboBox.SelectedItemProperty);
                        break;

                    case "SelectedValueBinding":
                        ApplyBinding(SelectedValueBinding, comboBox, ComboBox.SelectedValueProperty);
                        break;

                    case "TextBinding":
                        ApplyBinding(TextBinding, comboBox, ComboBox.TextProperty);
                        break;

                    case "SelectedValuePath":
                        DataGridHelper.SyncColumnProperty(this, comboBox, ComboBox.SelectedValuePathProperty, SelectedValuePathProperty);
                        break;

                    case "DisplayMemberPath":
                        DataGridHelper.SyncColumnProperty(this, comboBox, ComboBox.DisplayMemberPathProperty, DisplayMemberPathProperty);
                        break;

                    case "ItemsSource":
                        DataGridHelper.SyncColumnProperty(this, comboBox, ComboBox.ItemsSourceProperty, ItemsSourceProperty);
                        break;

                    default:
                        base.RefreshCellContent(element, propertyName);
                        break;
                    }
                }
            }
            else
            {
                base.RefreshCellContent(element, propertyName);
            }
        }
Beispiel #4
0
        protected internal override void RefreshCellContent(FrameworkElement element, string propertyName)
        {
            DataGridCell cell = element as DataGridCell;

            if (cell != null)
            {
                FrameworkElement textElement = cell.Content as FrameworkElement;

                if (textElement != null)
                {
                    switch (propertyName)
                    {
                    case "FontFamily":
                        DataGridHelper.SyncColumnProperty(this, textElement, TextElement.FontFamilyProperty, FontFamilyProperty);
                        break;

                    case "FontSize":
                        DataGridHelper.SyncColumnProperty(this, textElement, TextElement.FontSizeProperty, FontSizeProperty);
                        break;

                    case "FontStyle":
                        DataGridHelper.SyncColumnProperty(this, textElement, TextElement.FontStyleProperty, FontStyleProperty);
                        break;

                    case "FontWeight":
                        DataGridHelper.SyncColumnProperty(this, textElement, TextElement.FontWeightProperty, FontWeightProperty);
                        break;

                    case "Foreground":
                        DataGridHelper.SyncColumnProperty(this, textElement, TextElement.ForegroundProperty, ForegroundProperty);
                        break;
                    }
                }
            }

            base.RefreshCellContent(element, propertyName);
        }