Dynamic StripLines

Hello,

I wonder if there is a way to define strip lines in view models and bind them to the views? We have a requirement to dynamically define strip lines and the logic looks quite confusing if the only way to do this is code-behind.

Kind regards,
Valeriy

1 Reply 1 reply marked as answer

SM Saravanan Madheswaran Syncfusion Team February 24, 2021 08:51 AM UTC

Hi Valeriy, 
 
Greetings from Syncfusion support.  
 
We have prepared sleep-monitor like sample using DateTimeStripLineCollection by adding it from ViewModel. Please check the code snippet and sample below. 
 
Xaml: 
<chart:DateTimeAxis x:Name="XAxis" StripLines="{Binding StripLineCollection}"  
. . . 
</chart:DateTimeAxis> 
 
ViewModel: 
public DateTimeStripLineCollection StripLineCollection { get; set; } 
. . . 
. . . 
private void AddStripline(SleepingChartModel rate) 
    DateTimeStripLine stripLine = new DateTimeStripLine() 
   
 
        Start = rate.Minimum, 
        WidthType = DateTimeComponent.Minute, 
        Width = rate.SleepRange, 
        FillColor = rate.SleepMode == SleepMode.Awake ? Color.FromHex("#f3c137") : rate.SleepMode == SleepMode.DeepSleep ? Color.FromHex("#2a94f1") : rate.SleepMode == SleepMode.LightSleep ? Color.FromHex("#4ed0ff") : Color.FromHex("#ec9efd"), 
    }; 
 
    StripLineCollection.Add(stripLine); 
 
 
 
 
 
And please check the below guidelines to understand more on striplines. 
 
 
Regards, 
Saravanan. 


Marked as answer
Loader.
Up arrow icon