Search code examples
c#wpfxamllivecharts

How to make LabelFormatter only effect one bindling value by using LiveChart Gauge


I am using LiveChart Gauge to make a dashboard program. I want to display the value with % symbol, but it also change my Max value.

How can i only effect 1 binding value instead all binding value?

XAML

<lvc:Gauge Grid.Row="2" 
           Grid.Column="0" 
           Margin="15" 
           Foreground="White" 
           GaugeActiveFill="Yellow"
           From="0"
           To="{Binding totalTargetQuantity}"
           Value="{Binding ChartValue2}"
           LabelFormatter="{Binding Formatter2}"/>

Before use labelformatter

Before use labelformatter

After use labelformatter

After use labelformatter

Result that i need

Result that i need

Can anyone help me on this issue?


Solution

  • Same answer as Alexandr with modifications:

    Download and open LiveCharts.Wpf.dll with dnspy and find line:
    this.MeasureTextBlock.Text = (this.LabelFormatter ?? func)(this.Value);

    Click Edit Method and replace that line by:
    this.MeasureTextBlock.Text = "% " + (this.LabelFormatter ?? func)(this.Value);
    Now Click Compile.

    File -> Save Module -> LiveCharts.Wpf.dll
    Now this dll will show gauge like: