如何在后面的代码中旋转Silverlight轴标签 [英] How to rotate silverlight axis labes in code behind
问题描述
我需要在 CODE BEHIND 中旋转轴标签.
我的代码:
Hi I need rotate my axis labes in CODE BEHIND.
My code:
Style labelStyle = new Style(typeof(AxisLabel));
var setter = new Setter(AxisLabel.RenderTransformProperty, new RotateTransform() { Angle = -60, CenterX = 40, CenterY = 30 });
labelStyle.Setters.Add(setter);
看起来就像这个选择:
图片
问题在于,它会在某些坐标上旋转文本,并且会顺次运行.
有人可以帮我解决这个问题吗?我需要旋转标签,并且标签必须在X轴附近的相同点处结束或开始.
谢谢
我这样编辑我的代码:
And it look like on this pick :
Pic
The problem is, that it rotate text on some coordinates and it rly sux.
Can someone help me to fix it ? I need to rotate labels and it must end or start on the same points near axis X.
Thanks
I edit my code like this :
var setter2 = new Setter(AxisLabel.RenderTransformOriginProperty, "1,0");
var setter = new Setter(AxisLabel.RenderTransformProperty, new RotateTransform() { Angle = 270 });
但是那个b..ch仍然记得他的自动位置适合名字(1.上,2.下,3.上...)
Pic2
EDIT2 :
我试试这个:
But that b..ch still remember his auto making position for fit the names (1. up, 2. down, 3. up,...)
Pic2
EDIT2:
i try this :
var setter = new Setter(AxisLabel.RenderTransformProperty, new RotateTransform() { Angle = -60, CenterX = (double)GetValue(AxisLabel.ActualHeightProperty) / 2, CenterY = (double)GetValue(AxisLabel.ActualWidthProperty) /2});
但是实际的H/W始终是整个图形的H/W,而不是沿坐标轴的每个标签:/
我只是一个尝试在代码中旋转轴的人???
but actual H/W is always H/W of whole graph not each label in cathegory axis :/
I am only one who try rotate axis in code ???
推荐答案
Herez代码:
Herez the code:
var labelStyle = new Style(typeof(AxisLabel));
var rotate = new Setter(RotateTransform.AngleProperty, 270);
var setter = new Setter(AxisLabel.RenderTransformProperty, rotate);
labelStyle.Setters.Add(setter);
(xSerie.IndependentAxis as CategoryAxis).AxisLabelStyle = labelStyle;
这篇关于如何在后面的代码中旋转Silverlight轴标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!