Replies: 2 comments
-
|
So changing the XAML to <lvc:CartesianChart XAxes={Binding XAxes}>
<lvc:CartesianChart.Series>
<lvc:XamlColumnSeries SeriesName="Mary" Values="{Binding MaryValues}"/>
<lvc:XamlColumnSeries SeriesName="Ana" Values="{Binding AnaValues}"/>
</lvc:CartesianChart.Series>
</lvc:CartesianChart>And the MVVM model to namespace ViewModelsSamples.Bars.Basic;
public partial class ViewModel : ObservableObject
{
public List<double> MaryValues { get; set; } =
[2, 5, 4];
public List<double> AnaValues { get; set; } =
[3, 1, 6];
[ObservableProperty] private Axis[] _xAxes = { new Axis { Labels = new List<string>() } };
}Works fine and I don't have a single clue why is this working... Would be intersting if anyone can explain what is happening |
Beta Was this translation helpful? Give feedback.
-
|
Maybe if you specified it as <lvc:XamlAxis Labels="{Binding Path=Labels}" />, that could work? It appears your compiler is not fully "realizing" the path here and is thus trying to convert a literal string into an IList, and hence your StringArrayTypeConverter error. Usually, though, binding the entire XAxes collection has been the most stable approach for me in WPF; Livecharts2 wholly-supports MVVM, so it's usually best to instantiate your axes in the ViewModel if you're going to use any sort of Binding. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm learning Avalonia and XAML, and I have an exception that I don't understand.
And the XAML
If I run this code in an empty project it works.
If I run it In my application, with many things around as you can expect, this does not work and throws an exception.
And If I comment the XAxes the application works.
Since I'm very new to the XAML / Avalonia world, do you have any advice on how I should troubleshoot this kind of exception ?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions