dotnet/wpf · warning · InvalidOperationException

SR.DataGridColumnHeaderItemAutomationPeer_Unsupported

Error message

SR.DataGridColumnHeaderItemAutomationPeer_Unsupported

What it means

DataGridColumnHeaderItemAutomationPeer's ITransformProvider.Move is never supported: column headers cannot be repositioned by an x/y offset (drag-reorder is not expressed as a transform), so Move unconditionally throws InvalidOperationException with SR.DataGridColumnHeaderItemAutomationPeer_Unsupported.

Solutions

  1. Do not call Move on column headers; reorder columns via DataGrid.Columns collection manipulation instead.
  2. Catch InvalidOperationException and treat Move as unsupported (check pattern support before calling).
  3. If dragging is required, simulate input (mouse drag) rather than using ITransformProvider.
  4. Verify supported operations with automation pattern capability checks.

Example fix

// before
((ITransformProvider)headerPeer).Move(100, 0);

// after
dataGrid.Columns.Move(oldIndex, newIndex); // reorder via the collection
Defensive patterns

Strategy: try-catch

Validate before calling

// Move is never supported on column headers; do not call.

Try / catch

try { ((ITransformProvider)peer).Move(x, y); } catch (InvalidOperationException) { /* unsupported: reorder via Columns collection */ }

Prevention

When it happens

Trigger: Any automation client calling ITransformProvider.Move(x, y) on a DataGrid column header peer — there is no condition; the operation is always rejected.

Common situations: UIA transform-pattern scripts attempting to move/drag headers programmatically; accessibility tools exposing Transform pattern on headers; automation attempting column reorder via Move instead of the proper drag mechanism.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/c3293d6a19e5a532. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/DataGridColumnHeaderItemAutomationPeer.cs:166

            get 
            { 
                if (this.Column != null)
                    return Column.CanUserResize;
                return false;
            } 
        }

        bool ITransformProvider.CanRotate 
        { 
            get 
            { 
                return false; 
            } 
        }

        void ITransformProvider.Move(double x, double y)
        {
            throw new InvalidOperationException(SR.DataGridColumnHeaderItemAutomationPeer_Unsupported);
        } 

        void ITransformProvider.Resize(double width, double height)
        {
            if (this.OwningDataGrid != null && Column.CanUserResize)
            {
                Column.Width = new DataGridLength(width);
            }
            else
            {
                throw new InvalidOperationException(SR.DataGridColumnHeaderItemAutomationPeer_Unresizable);
            }
        }

        void ITransformProvider.Rotate(double degrees)
        {
            throw new InvalidOperationException(SR.DataGridColumnHeaderItemAutomationPeer_Unsupported);
        }

View on GitHub (pinned to 81131a70a4)