开发者

Changing textblock origin in WPF

I have a textblock placed at the point 250, 250 (X: 250, Y: 250). Using a dot as reference, I can see that the textblock is placed at the origin 0,0 (of the textblock). Is there anyway to change the origin to, say, the center of the textbox, or开发者_如何学Python the lower right hand corner?


I found that RenderTransformOrigin() works quite well, especially if you need to change the origin because of a transform.

textBlock.RenderTransformOrigin = new Point(0.5, 0.5); will specify the origin in the middle .

From MSDN:

RenderTransformOrigin has a somewhat nonstandard use of the Point structure value, in that the Point does not represent an absolute location in a coordinate system. Instead, values between 0 and 1 are interpreted as a factor for the range of the current element in each x,y axis. For example, (0.5,0.5) will cause the render transform to be centered on the element, or (1,1) would place the render transform at the bottom right corner of the element. NaN is not an accepted value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜