Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5846083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:31:36+00:00 2026-05-22T12:31:36+00:00

I have a pretty simple user control that I want to bind a ScaleTransform

  • 0

I have a pretty simple user control that I want to bind a ScaleTransform property to a DP in the code behind like so:

<UserControl 
x:Name="RoundByRound"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
...
>

<Canvas x:Name="MyCanvas">
  <Canvas.RenderTransform>
    <TransformGroup>
      <ScaleTransform ScaleX="{Binding ZoomTransform.ScaleX, ElementName=RoundByRound}" 
                      ScaleY="{Binding ZoomTransform.ScaleY, ElementName=RoundByRound}"/>
      <SkewTransform/>
      <RotateTransform/>
      <TranslateTransform X="{Binding TranslateTransform.X, ElementName=RoundByRound}" 
                          Y="{Binding TranslateTransform.Y, ElementName=RoundByRound}"/>
     </TransformGroup>
   </Canvas.RenderTransform>
</Canvas>
</UserControl>

and then in the code behind I do this:

ZoomTransform.ScaleX = 3;
ZoomTransform.ScaleY = 3;

But I got an error saying:

Cannot set a property on object ‘…’ because it is in a read-only state.

So I changed it to:

var cloned = ZoomTransform.Clone();
cloned.ScaleX = 3;
cloned.ScaleY = 3;
ZoomTransform = cloned;

But now that actually does nothing… no scale gets applied to my canvas.

HOWEVER

If I remove the binding on the ScaleTransform and just have it as an empty XAML element:

<ScaleTransform />

Then in my code I do this:

(MyCanvas.RenderTransform as TransformGroup).Children[0] = new ScaleTransform(3, 3);

It works! I get the scale applied

So 2 questions:

  1. Why is my Transform Frozen is the first place?
  2. Why doesnt my binding work when I clone the transform?

Thanks all!

UPDATE:

Here is the definition of the DP:

public static readonly DependencyProperty TranslateTransformProperty = DependencyProperty.Register("TranslateTransform",
            typeof(TranslateTransform),
            typeof(RoundByRoundControl),
            new PropertyMetadata(new TranslateTransform { X = 0, Y = 0 }));

        public static readonly DependencyProperty ZoomTransformProperty = DependencyProperty.Register("ZoomTransform",
            typeof(ScaleTransform),
            typeof(RoundByRoundControl),
            new PropertyMetadata(new ScaleTransform { ScaleX = 1, ScaleY = 1 }));

        public TranslateTransform TranslateTransform
        {
            get { return (TranslateTransform)GetValue(TranslateTransformProperty); }
            set { SetValue(TranslateTransformProperty, value); }
        }

        public ScaleTransform ZoomTransform
        {
            get { return (ScaleTransform)GetValue(ZoomTransformProperty); }
            set { SetValue(ZoomTransformProperty, value); }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:31:37+00:00Added an answer on May 22, 2026 at 12:31 pm

    The ScaleTransform that you pass as your default value for your ZoomTransform property is frozen by the PropertyMetadata. Once the PropertyMetadata is passed to the Register method is will be frozen/sealed.

    However, once the metadata is consumed
    as part of a call to Register,
    AddOwner, or OverrideMetadata, the
    property system will seal that
    metadata instance and the properties
    are now considered immutable.
    Attempting to set DefaultValue once
    IsSealed is true on this metadata
    instance will raise an exception.

    Since the ScaleTransform is a Freezable, it is frozen as part of this process.

    As for you second question, based on the code you provided it does correctly apply the ScaleTransform when cloning the ZoomTransform. There must be something else going on that you haven’t included.

    This is assuming that the XAML for your UserControl includes an x:Class attribute which ties to the code-behind file for RoundByRoundControl.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should be pretty simple: I have an InputStream where I want to peek at
Pretty simple question: When i have a persistable object, it usually has a property
Pretty simple scenario. I have a web service that receives a byte array that
I have pretty big background of .net, and I've decided that i want to
I have a pretty simple requirement. If the user goes to http://www.somedomain.com/ and is
I have a pretty simple MVC 2 form. It has two dropdowns, user and
I have a python question that I'm sure is pretty simple - please feel
This one should be pretty simple. The use case is that I have a
I am pretty new to php, but I am learning! I have a simple
I would like to have pretty URLs for my tagging system along with all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.