![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Applying a centered ScaleTransform via a Style Hi, I would like to apply a ScaleTransform to a control via a Style. This is easy enough: <Setter Property="RenderTransform"> <Setter.Value> <ScaleTransform ScaleX="1.25" ScaleY="1.25" /> </Setter.Value> </Setter> But I would like this ScaleTransform to be centered on the control. I know the CenterX and CenterY properties exist for this purpose, but the problem is that their value is dynamic (Control.Width/2, Control.Height/2) and being in a Style declaration I do not know up front the Width/Height of the control being styled. Is there a way to specify an expression such as Width/2 declaratively in XAML? Thanks! Pascal |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Applying a centered ScaleTransform via a Style There is no way to place an expression as an attribute value, and I do not believe binding will solve this either, although you might be able to bind the CenterX and CenterY properties to the control on which it is applied. If that worked you could then create attached properties that are really derived values using the expression you suggest. Probably an easier approach would be to create a sub-type of ScaleTransform that computes CenterX and CenterY dynamically. Michael Microsoft MVP (C# / WPF) "Pascal Bourque" <bourquep@xceedsoft.com> wrote in message news:upe58hrIGHA.3364@tk2msftngp13.phx.gbl... > Hi, > > I would like to apply a ScaleTransform to a control via a Style. This is > easy enough: > > <Setter Property="RenderTransform"> > <Setter.Value> > <ScaleTransform ScaleX="1.25" > ScaleY="1.25" /> > </Setter.Value> > </Setter> > > But I would like this ScaleTransform to be centered on the control. I know > the CenterX and CenterY properties exist for this purpose, but the problem > is that their value is dynamic (Control.Width/2, Control.Height/2) and > being in a Style declaration I do not know up front the Width/Height of > the control being styled. > > Is there a way to specify an expression such as Width/2 declaratively in > XAML? > > Thanks! > > Pascal |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Applying a centered ScaleTransform via a Style Thanks for the suggestions, Michael! I will try deriving form ScaleTransform and post the results here! Pascal Michael Latta wrote: > There is no way to place an expression as an attribute value, and I do not > believe binding will solve this either, although you might be able to bind > the CenterX and CenterY properties to the control on which it is applied. > If that worked you could then create attached properties that are really > derived values using the expression you suggest. Probably an easier > approach would be to create a sub-type of ScaleTransform that computes > CenterX and CenterY dynamically. > > Michael > Microsoft MVP (C# / WPF) > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Applying a centered ScaleTransform via a Style Instead of setting the CenterX and CenterY properties of the ScaleTransform, set the RenderTransformOrigin property of the object to 0.5,0.5. That will center your ScaleTransform automatically. See http://windowssdk.msdn.microsoft.com...formOrigin.asp for more information about the RenderTransformOrigin property. **** Mike Jacobs [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights. **** "Pascal Bourque" <bourquep@xceedsoft.com> wrote in message news:uYS6d7qJGHA.3856@TK2MSFTNGP12.phx.gbl... > Thanks for the suggestions, Michael! I will try deriving form > ScaleTransform and post the results here! > > Pascal > > Michael Latta wrote: >> There is no way to place an expression as an attribute value, and I do >> not believe binding will solve this either, although you might be able to >> bind the CenterX and CenterY properties to the control on which it is >> applied. If that worked you could then create attached properties that >> are really derived values using the expression you suggest. Probably an >> easier approach would be to create a sub-type of ScaleTransform that >> computes CenterX and CenterY dynamically. >> >> Michael >> Microsoft MVP (C# / WPF) >> |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Set Desktop Background as Centered | Vista General | |||
| Font Size - XP style vs Vista style | Vista General | |||
| Font Size - XP style vs Vista style | Vista General | |||
| Font Size - XP style vs Vista style | Vista General | |||