Hello,
I’m currently rewriting a program in .net7 WPF using MVVM as much as possible.
In my MainViewModel:
I read data from a CSV file and transforming it into an ObservableCollection of LineRenderableSeriesViewModel (stored in the « RenderableSeriesViewModels » variable) . Additionally, the Y axes are transformed into ObservableCollection of IAxisViewModel (within the « Yaxes » variable).
Each series corresponds to a LineRenderableSeriesViewModel and each Y axis is represented as a NumericAxisViewModel. The X-axis is a DateTime common to all series and is declared only in XAML.
Within my view’s XAML:
I declare RenderableSeries=”{s:SeriesBinding RenderableSeriesViewModels}” and YAxes=”{s:AxesBinding YAxes}. I’ve defined a legend template to add several elements:
– DataContext=”{Binding RenderableSeries}”
– A checkbox to toggle serie visibility (IsVisible binding).
– A checkbox to toggle Y-axis visibility for the serie (YAxis.Visibility binding).
– A color picker to change the color of a serie, bound to “Stroke”, “YAxis.TickTextBrush”, and “YAxis.BorderBrush”
– A slider for adjusting serie thickness (StrokeThickness binding).
Results:
Each element acts on the graph as expected: RenderableSeries updates and the graph refreshes correctly.
In the MainViewModel, RenderableSeriesViewModels and YAxes are not updated for all elements:
– “IsVisible” and “StrokeThickness” for the concerned series are instantly modified in RenderableSeriesViewModels but “Stroke” is not.
– “YAxes” is not updated.
The code for the LegendTemplate and a screenshot of the resulting legend are in the attachements.
Could you please help me to understand what I do wrong?
- Nicolas MARTINEZ asked 1 month ago
- last active 5 days ago
I made wpf project with MVVM. I added LineRenderableSeriesViewModel to the model. SelectedSeriesStyle contains StrokeThickness=3 property. When I click on series, the SeriesSelectionModifier set correctly the line thicknes, but when I set IsSelected property in model, the seriesline thickness not changing. The stroke and PointMarkerTemplate properties work correctly.
Why not changing StrokeThickness property by model?
- Zsolt Huse asked 4 years ago
- last active 4 years ago