Exemplo n.º 1
0
        private static object OnCoerceDetailsTemplateSelector(DependencyObject d, object baseValue)
        {
            var row = (DataGridRow)d;

            return(DataGridHelper.GetCoercedTransferPropertyValue(
                       row,
                       baseValue,
                       DetailsTemplateSelectorProperty,
                       row.DataGridOwner,
                       DataGrid.RowDetailsTemplateSelectorProperty));
        }
Exemplo n.º 2
0
        private static object OnCoerceValidationErrorTemplate(DependencyObject d, object baseValue)
        {
            var row = (DataGridRow)d;

            return(DataGridHelper.GetCoercedTransferPropertyValue(
                       row,
                       baseValue,
                       ValidationErrorTemplateProperty,
                       row.DataGridOwner,
                       DataGrid.RowValidationErrorTemplateProperty));
        }
Exemplo n.º 3
0
        private static object OnCoerceHeaderStyle(DependencyObject d, object baseValue)
        {
            var row = (DataGridRow)d;

            return(DataGridHelper.GetCoercedTransferPropertyValue(
                       row,
                       baseValue,
                       HeaderStyleProperty,
                       row.DataGridOwner,
                       DataGrid.RowHeaderStyleProperty));
        }
        private static object OnCoerceStyle(DependencyObject d, object baseValue)
        {
            var cell = d as DataGridCell;

            return(DataGridHelper.GetCoercedTransferPropertyValue(
                       cell,
                       baseValue,
                       StyleProperty,
                       cell.Column,
                       DataGridColumn.CellStyleProperty,
                       cell.DataGridOwner,
                       DataGrid.CellStyleProperty));
        }
        private static object OnCoerceIsReadOnly(DependencyObject d, object baseValue)
        {
            var cell     = d as DataGridCell;
            var column   = cell.Column;
            var dataGrid = cell.DataGridOwner;

            // We dont use the cell & 'baseValue' here because this property is read only on cell.
            // the column may coerce a default value to 'true', so we'll use it's effective value for IsReadOnly
            // as the baseValue.
            return(DataGridHelper.GetCoercedTransferPropertyValue(
                       column,
                       column.IsReadOnly,
                       DataGridColumn.IsReadOnlyProperty,
                       dataGrid,
                       DataGrid.IsReadOnlyProperty));
        }
Exemplo n.º 6
0
        private static object OnCoerceDetailsVisibility(DependencyObject d, object baseValue)
        {
            var    row        = (DataGridRow)d;
            object visibility = DataGridHelper.GetCoercedTransferPropertyValue(
                row,
                baseValue,
                DetailsVisibilityProperty,
                row.DataGridOwner,
                DataGrid.RowDetailsVisibilityModeProperty);

            if (visibility is DataGridRowDetailsVisibilityMode)
            {
                var visibilityMode     = (DataGridRowDetailsVisibilityMode)visibility;
                var hasDetailsTemplate = row.DetailsTemplate != null || row.DetailsTemplateSelector != null;
                var isRealItem         = row.Item != CollectionView.NewItemPlaceholder;
                switch (visibilityMode)
                {
                case DataGridRowDetailsVisibilityMode.Collapsed:
                    visibility = Visibility.Collapsed;
                    break;

                case DataGridRowDetailsVisibilityMode.Visible:
                    visibility = hasDetailsTemplate && isRealItem ? Visibility.Visible : Visibility.Collapsed;
                    break;

                case DataGridRowDetailsVisibilityMode.VisibleWhenSelected:
                    visibility = row.IsSelected && hasDetailsTemplate && isRealItem ? Visibility.Visible : Visibility.Collapsed;
                    break;

                default:
                    visibility = Visibility.Collapsed;
                    break;
                }
            }

            return(visibility);
        }