dotnet/wpf · error · InvalidOperationException

SR.TransformNotSupported

Error message

SR.TransformNotSupported

What it means

A top-level HWND window cannot be rendered with arbitrary transforms (rotation, skew, scale); the OS composits the window as a whole. Window.CoerceRenderTransform allows only an identity (or null) RenderTransform and throws InvalidOperationException for any real transform. This is a deliberate WPF restriction on the Window class, not a bug.

Solutions

  1. Remove the RenderTransform from the Window and apply it to an inner root element (e.g. Grid or Border) instead
  2. Animate/transform the root child element's RenderTransform rather than the window's
  3. If a transform on the window itself is truly needed, host content in a borderless window and transform inner content

Example fix

// before
<Window RenderTransform="..."><Grid/></Window>
// after
<Window><Grid RenderTransform="...">...</Grid></Window>
Defensive patterns

Strategy: validation

Validate before calling

bool canApply = window.RenderTransform == null || window.RenderTransform is Transform t && t.Value.IsIdentity;

Type guard

static bool IsIdentityTransform(Transform t) => t == null || t.Value.IsIdentity;

Try / catch

try { window.RenderTransform = transform; } catch (InvalidOperationException) { rootElement.RenderTransform = transform; }

Prevention

When it happens

Trigger: Assigning a non-identity Transform (RotateTransform, ScaleTransform, TranslateTransform with non-zero values, TransformGroup, etc.) to Window.RenderTransform in code or XAML, or via a binding/style that applies a transform to the window.

Common situations: Copying a control's style/template to a Window, databinding RenderTransform with an animated transform, applying an entrance animation transform to the whole window.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs:6307

                using (HwndStyleManager sm = HwndStyleManager.StartManaging(this, StyleFromHwnd, StyleExFromHwnd ))
                {
                    CreateRtl();
                }
            }
        }

        private static object CoerceRenderTransform(DependencyObject d, object value)
        {
            Transform renderTransformValue = (Transform)value;

            if ((value == null) ||
                (renderTransformValue != null && renderTransformValue.Value.IsIdentity))
            {
                // setting this value is allowed.
            }
            else
            {
                throw new InvalidOperationException(SR.TransformNotSupported);
            }

            return value;
        }

        private static void _OnRenderTransformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
        }

        private static object CoerceClipToBounds(DependencyObject d, object value)
        {
            if ((bool)value)
            {
                throw new InvalidOperationException(SR.ClipToBoundsNotSupported);
            }
            return value;
        }

View on GitHub (pinned to 81131a70a4)