I am trying to bind StrokeDashArray to a property in my ViewModel, which is an enum (Solid, Dash, Dot), using a value converter.
The binding works as expected for HorizontalLineAnnotation, but it does not work for FastLineRenderableSeries or MajorGridLineStyle.
Works
<s:HorizontalLineAnnotation StrokeDashArray="{Binding LineStyle, Converter={StaticResource DashConverter}}" />
<s:FastLineRenderableSeries StrokeDashArray="4,4" />
Does NOT work, always display solid line
<s:FastLineRenderableSeries StrokeDashArray="{Binding LineStyle, Converter={StaticResource DashConverter}}" />
Converter Code
public enum LineStyle { Solid, Dash, Dot }
public class DashConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Enum.TryParse(value.ToString(), out LineStyle lineStyle);
switch (lineStyle)
{
case LineStyle.Dash:
return new DoubleCollection(new double[] { 4, 4 });
case LineStyle.Dot:
return new DoubleCollection(new double[] { 1, 4 });
}
return new DoubleCollection();//Solid
}
- Rachel Shavdron asked 1 month ago
- last edited 1 month ago
- Hi Rachel, Thanks for your inquiry. Unfortunately, it looks like the “Works” and “Does NOT work” sections of your message miss additional details. Could you please resend them? Thanks in advance, Lex, SciChart Technical Support Engineer
- You must login to post comments
Hi Rachel,
I hope this message finds you well.
Thank you for reporting this.
There are currently different types of StrokeDashArray properties (please see the attached image).
We plan to fix this in the future SciChart releases.
For now, we recommend using the customized converter, which will check the targetType.
We’ve prepared a sample project featuring the mentioned converter for your convenience. Please find it attached.
Kind regards,
Lex,
SciChart Technical Support Engineer
- Lex answered 6 days ago
- You must login to post comments
Please login first to submit.