问题
I am displaying data in my livecharts and Label values are binded (visible in debugging). But somehow in the UI, it is showing one or two values instead of all the values in string array from the backend.
Model.cs Code:
private string[] _Labels;
public string[] Labels
{
get
{
return _Labels;
}
set
{
SetProperty(ref _Labels, value);
}
}
ModelViewCode.cs
Labels = new[] {"Maria", "Susan", "Charles", "Frida"};
XAML:
<lvc:CartesianChart.AxisX>
<lvc:Axis Labels="{Binding Labels}">
</lvc:Axis>
</lvc:CartesianChart.AxisX>
Screenshot
回答1:
Define an AxisSeparator for your axis like this, and set its Step
property to 1
<lvc:CartesianChart.AxisX>
<lvc:AxesCollection>
<lvc:Axis Labels="{Binding Labels}">
<lvc:Axis.Separator>
<lvc:Separator Step="1" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:AxesCollection>
</lvc:CartesianChart.AxisX>
来源:https://stackoverflow.com/questions/48315993/livecharts-not-displaying-label-on-x-axis-in-wpf