Search code examples
c#wpfsilverlighttranslate

Automatic translate transform with respect to borders in WPF


I need to have my TextBox translated by the vector, say X = 10, Y = 10 , when the TextBox is placed in the top left corner of my window. However, if it's situated in the right bottom corner, it should be translated by the vector X = -10, Y = -10.

I wonder, if it is possible to set the translate transform for a certain control according to its position (bottom-right/left / top-right/left) by a quick hack.

Do you have any ideas?

Cheers.


Solution

  • You need to have two property XValue and YValue, based on the orientation you need to coerce the value using CoerceValueCallback of the dependency property.

    http://msdn.microsoft.com/en-us/library/system.windows.coercevaluecallback.aspx HTH