Я немного изменил ваш xaml
.
<charting:Chart>
<charting:ColumnSeries x:Name="CS" ItemsSource="{Binding Items}" IndependentValuePath="X" DependentValuePath="Y">
<charting:ColumnSeries.IndependentAxis>
<charting:CategoryAxis Orientation="X" />
</charting:ColumnSeries.IndependentAxis>
</charting:ColumnSeries>
</charting:Chart>
Вышеприведенный xaml можно записать на c # так:
var CS = new ColumnSeries
{
ItemsSource = model.Items,
IndependentValuePath = "X",
DependentValuePath = "Y",
IndependentAxis = new CategoryAxis { Orientation = AxisOrientation.X }
};
А теперь в коде позади вы можете установитьсвойство AxisLabelStyle
следующим образом:
var labelStyle = new Style(typeof(AxisLabel));
labelStyle.Setters.Add(new Setter(AxisLabel.StringFormatProperty, "Category {0}"));
var axis = (CategoryAxis)CS.IndependentAxis;
axis.AxisLabelStyle = labelStyle;
Не забудьте привести свойство IndependentAxis
к правильному типу, потому что по умолчанию оно имеет тип IAxis
, который не имеетстиль метки.