Click here to Skip to main content
15,891,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Hi,

Is they any method to make the WPF X-axis label to get align (such as textalignment). I do try to on the code below but it does not yield any positive outcome

Outcome of X-axis label:
Hide   Copy Code
1111   3333   5555
   2222   4444   6666

Desire outcome of X-axis label:
1111 2222 3333 4444 5555 6666


What I have tried:

C#
CategoryAxis IndependentAxis = new CategoryAxis();
IndependentAxis.Orientation = AxisOrientation.X;
IndependentAxis.Location = AxisLocation.Bottom;
IndependentAxis.ShowGridLines = false;
 
var rotateLabel = new Style(typeof(AxisLabel));
rotateLabel.Setters.Add(
    new Setter(
        AxisLabel.RenderTransformProperty,
        new RotateTransform() { Angle = -90, CenterY = 20, CenterX = 30 }));
 
rotateLabel.Setters.Add(new Setter(AxisLabel.HorizontalContentAlignmentProperty, HorizontalAlignment.Right));
 
IndependentAxis.AxisLabelStyle = rotateLabel;
lineChart.Axes.Add(IndependentAxis);
Posted
Updated 4-Sep-16 15:00pm
Comments
sacpundir 25-Aug-16 10:34am    
Please provide more information. as per my first opinion your label don't have enough space.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900