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 6126817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:25:27+00:00 2026-05-23T16:25:27+00:00

I am experiencing a weird problem with a render transform in WPF. The project

  • 0

I am experiencing a weird problem with a render transform in WPF. The project I’m working on needs to display a clicked user point over an image. When the user clicks a point, a custom control is placed at the location of their click. The image should then be able to be scaled around any point using the mouse wheel, and the custom control should be translated (not scaled) to the correct location.

To do this, I follow the MouseWheel event as follows:

private void MapPositioner_MouseWheel(object sender, MouseWheelEventArgs e)
{   
    Point location = Mouse.GetPosition(MainWindow.Instance.imageMap);

    MainWindow.Instance.imageMap.RenderTransform = null;

    ScaleTransform st = new ScaleTransform(scale + (e.Delta < 0 ? -0.2 : 0.2), scale += (e.Delta < 0 ? -0.2 : 0.2));
    st.CenterX = location.X;
    st.CenterY = location.Y;


    TransformGroup tg = new TransformGroup();
    tg.Children.Add(st);
    //tg.Children.Add(tt);

    MainWindow.Instance.imageMap.RenderTransform = tg;

    if (scale <= 1)
    {
        MainWindow.Instance.imageMap.RenderTransform = null;
    }

    if (TransformationChanged != null)
        TransformationChanged();
}

Then, I implemented an event handler in the custom control for the TransformationChanged event seen at the end of the above code block as follows:

private void Instance_TransformationChanged()
    {
        //check image coords
        //
        if (MainWindow.Instance.imageMap.RenderTransform != null)
        {
            if (MainWindow.Instance.imageMap.RenderTransform != Transform.Identity)
            {
                Transform st = MainWindow.Instance.imageMap.RenderTransform;

                Point image = MainWindow.VideoOverlayCanvas.TransformToVisual(MainWindow.Instance.MapImage).Transform(loc2);

                Point trans = st.Transform(image);

                Point final = MainWindow.Instance.MapImage.TransformToVisual(MainWindow.VideoOverlayCanvas).Transform(trans);

               // selected = anchor2;
               // final = ClipToOverlay(final);
               // selected = null;

                connector.X2 = final.X;
                connector.Y2 = final.Y;

                Canvas.SetLeft(anchor2, final.X);
                Canvas.SetTop(anchor2, final.Y);                    
            }
        }
        else
        {
            connector.X2 = loc2.X;
            connector.Y2 = loc2.Y;

            Canvas.SetLeft(anchor2, loc2.X);
            Canvas.SetTop(anchor2, loc2.Y);
        }
    }

This way, I can ensure that the custom control’s position is updated only after the new transform is set. Note that since I am applying the transform to the point, there is no scaling done to the control, the effect is that it is translated to the point it should. This works fine as long as the user is only scaling around one point. If they change that point, it doesnt work.
Here are some images that show the problem:

User clicks a point

user zooms out, what happened here?

after zooming out (all the way out in this case) it looks ok

I’ve been messing with this for about two days now, so I apologize if my code looks messy. I know this is a pretty obscure question so any help would be appreciated.

Thanks,
Max

  • 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-23T16:25:28+00:00Added an answer on May 23, 2026 at 4:25 pm

    If anyone is looking for an answer to this, because of deadlines, I had to write a workaround by having the user pan with the right mouse button and zoom with the mouse wheel. This way zooming always happens around the center of the image, so the controls are always lined up. I’m still looking for answers to the original question though if anyone can figure it out

    Thanks,

    Max

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

Sidebar

Related Questions

I'm experiencing this weird problem which my scrollbar jumps by itself to somewhere that
I'm currently working with jQuery 1.4.2 and jQuery UI 1.8.2. I'm experiencing some weird
I'm experiencing a weird problem with a SQL login. When I connect to the
Hi I'm experiencing a super weird problem. Whenever I post links to my website
I am an enthousiastic (new) user of structuremap but I am experiencing a problem
I am experiencing some weird encoding behaviour in my ASP.NET MVC project. In my
I'm experiencing a (for me) very weird problem in Python. I have a class
I'm experiencing this weird problem reading data from a table called nodes. Any select
I am currently experiencing a weird caching problem it would seem. When I load
I have been experiencing a weird problem that I can't find a solution to.

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.