473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to set ScaleTransform.CenterX in code?

Anyone know how to set the CenterX property of a ScaleTransform (on an
Image object) NOT using XAML?

Here is how I do this in XAML:

<Image Grid.Row="0"
Name="image1"
MouseMove="image1_MouseMove"
MouseDown="image1_MouseDown"
MouseUp ="image1_MouseUp">
<Image.RenderTransform>
<ScaleTransform ScaleX="2" ScaleY="2" CenterX="250"
CenterY="200">
</ScaleTransform>
</Image.RenderTransform>
</Image>

The problem is, I need to set CenterX and CenterY dynamically to the
center of the window, which can be resized at any time by the user.

Thanks
-Dean
Jun 27 '08 #1
2 5859
Anyone know how tosetthe CenterX property of a ScaleTransform (on an
Image object) NOT using XAML?
If you've already got a transform defined in XAML (as in your example) then
you can change its properties by code like:
((ScaleTransform)image1.RenderTransform).CenterX = newValue;

You could also use databinding to bind the centerX and CenterY properties to
the window's ActualWidth and ActualHeight, though you'd need to use a
ValueConverter to divide the values by 2 (or use Kent Boogaart's
ExpressionConverter - see
http://www.codeplex.com/wpfconverter...ingTitle=Home).

Chris Jobson
Jun 27 '08 #2
On Jun 12, 2:16*pm, "Chris Jobson" <chris.job...@btinternet.com>
wrote:
Anyone know how tosetthe CenterX property of a ScaleTransform (on an
Image object) NOT using XAML?

If you've already got a transform defined in XAML (as in your example) then
you can change its properties by code like:
((ScaleTransform)image1.RenderTransform).CenterX = newValue;

You could also use databinding to bind the centerX and CenterY properties to
the window's ActualWidth and ActualHeight, though you'd need to use a
ValueConverter to divide the values by 2 (or use Kent Boogaart's
ExpressionConverter - seehttp://www.codeplex.com/wpfconverters/Wiki/View.aspx?title=User%20Doc...).

Chris Jobson
Thanks Chris that works well.

-Dean
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jeroen | last post by:
Hi, I'm searching but not finding :( I need the code that creates automatic the days in a month So like for this month, it creates the days in this format 01-Oct, 02-Oct, .... This...
18
by: Phill Long | last post by:
this is the the code, now here is the final result.... I get one combo box and one tex box come up, but they are empty... DAMN!!! Any ideas on what Im doing wrong please.. Thanks Again <?php...
12
by: lawrence | last post by:
I have a string which I want to send to eval(). How can I test it ahead of time to make sure it is valid code? I don't want to send it to eval and get parse errors. I want to do something like...
51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
22
by: Harold Crump | last post by:
Greetings, I have a PHP/MySQL application that I am deploying at a client's. I am fairly certain that they will steal my source code and re-sell to other companies. I would like to somehow...
9
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
3
by: Arvie | last post by:
I need some advice guys.. I am proposing that we get someone to do a complete audit/review of our Java application codebase, about 1000 JSPs/Servlets and 100 EJBs. If I get firms to submit...
4
by: Michael Chermside | last post by:
Will Stuyvesant writes: > If you know that your source code is going to be used > later by others, then I feel that code with the pattern: > > if some_condition: > some_name =...
0
by: Dad | last post by:
Hi, I am trying to redefine the drawing coordinates of a window to be 0.0 .. 1.0 in both axes with the origin at the lower left corner. The origin transform (Graphics.TranslateTransform) works...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.