How to bind to Classes?

Fundamentals for Avalonia Forum

Posted 18 days ago by Michael Janulaitis - Corner Bowl Software
Avatar

I am using LiveCharts2's Pie Chart to implement my dounut percentage gauge in my WPF app.  Although I need to get LiveCharts2 working in my Avalonia project, at the moment this is not a priority and I am instead using the AcitPro.CircularProgressBar.  This works great however I would like to set the color manually when thresholds are breached.  I see the colors are set as a style rather than a HEX or uint color value.  Ideally I would like to bind the color but if that's not going to be an option how can I set the class with a binding convertor?

Comments (1)

Posted 16 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Avalonia does not currently support updating classes via a setter, but you should be able to fully control the colors of the progress bar without using classes.  When you say "colors are set as a style", I assume you are referring to the semantic color variants like accent, danger, success, and warning.  In the case of CircularProgressBar, these variants are simply used by the default control theme to change the IndicatorBrush property, as shown in the snippet below:

<!-- accent -->
<Style Selector="^.accent">
	<Setter Property="IndicatorBrush" Value="{actipro:ThemeResource ControlBackgroundBrushSolidAccent}" />
</Style>

<!-- danger -->
<Style Selector="^.danger">
	<Setter Property="IndicatorBrush" Value="{actipro:ThemeResource ControlBackgroundBrushSolidDanger}" />
</Style>

<!-- success -->
<Style Selector="^.success">
	<Setter Property="IndicatorBrush" Value="{actipro:ThemeResource ControlBackgroundBrushSolidSuccess}" />
</Style>

<!-- warning -->
<Style Selector="^.warning">
	<Setter Property="IndicatorBrush" Value="{actipro:ThemeResource ControlBackgroundBrushSolidWarning}" />
</Style>

Here the IndicatorBrush property is updated to one of our predefine theme resources that correspond to the semantic color variant.  In your scenario, you could update the IndicatorBrush property directly based on the value thresholds you define.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.