示例#1
0
        /// <summary>
        /// Override which rebuilds the cell's visual tree for ContentBinding change
        /// and Modifies Hyperlink for TargetName change
        /// </summary>
        /// <param name="element"></param>
        /// <param name="propertyName"></param>
        protected internal override void RefreshCellContent(FrameworkElement element, string propertyName)
        {
            DataGridCell cell = element as DataGridCell;

            if (cell != null && !cell.IsEditing)
            {
                if (string.Compare(propertyName, "ContentBinding", StringComparison.Ordinal) == 0)
                {
                    cell.BuildVisualTree();
                }
                else if (string.Compare(propertyName, "TargetName", StringComparison.Ordinal) == 0)
                {
                    TextBlock outerBlock = cell.Content as TextBlock;
                    if (outerBlock != null && outerBlock.Inlines.Count > 0)
                    {
                        Hyperlink link = outerBlock.Inlines.FirstInline as Hyperlink;
                        if (link != null)
                        {
                            link.TargetName = TargetName;
                        }
                    }
                }
            }
            else
            {
                base.RefreshCellContent(element, propertyName);
            }
        }
        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);
            }
        }
示例#3
0
        /// <summary>
        /// Override which rebuilds the cell's visual tree for Binding change
        /// </summary>
        /// <param name="element"></param>
        /// <param name="propertyName"></param>
        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, "Binding", StringComparison.Ordinal) == 0) ||
                    (string.Compare(propertyName, "ElementStyle", StringComparison.Ordinal) == 0 && !isCellEditing) ||
                    (string.Compare(propertyName, "EditingElementStyle", StringComparison.Ordinal) == 0 && isCellEditing))
                {
                    cell.BuildVisualTree();
                    return;
                }
            }

            base.RefreshCellContent(element, propertyName);
        }
示例#4
0
        /// <summary>
        /// Override which handles property
        /// change for template properties
        /// </summary>
        /// <param name="element"></param>
        /// <param name="propertyName"></param>
        protected internal override void RefreshCellContent(FrameworkElement element, string propertyName)
        {
            DataGridCell cell = element as DataGridCell;

            if (cell != null)
            {
                bool isCellEditing = cell.IsEditing;

                if ((!isCellEditing &&
                     ((string.Compare(propertyName, "CellTemplate", StringComparison.Ordinal) == 0) ||
                      (string.Compare(propertyName, "CellTemplateSelector", StringComparison.Ordinal) == 0))) ||
                    (isCellEditing &&
                     ((string.Compare(propertyName, "CellEditingTemplate", StringComparison.Ordinal) == 0) ||
                      (string.Compare(propertyName, "CellEditingTemplateSelector", StringComparison.Ordinal) == 0))))
                {
                    cell.BuildVisualTree();
                    return;
                }
            }

            base.RefreshCellContent(element, propertyName);
        }