Back to Devexpress

ScaleLabelOptions.FormatString Property

wpf-devexpress-dot-xpf-dot-gauges-dot-scalelabeloptions-8eb6d1c7.md

latest5.1 KB
Original Source

ScaleLabelOptions.FormatString Property

Gets or sets a value that specifies the format string for the display text on a scale.

Namespace : DevExpress.Xpf.Gauges

Assembly : DevExpress.Xpf.Gauges.v25.2.dll

NuGet Package : DevExpress.Wpf.Gauges

Declaration

csharp
public string FormatString { get; set; }
vb
Public Property FormatString As String

Property Value

TypeDescription
String

A String value that is the format string of a label.

|

Remarks

Use the FormatString property to define the specific string format for the scale’s label.

The following images illustrate some of string formats for the Circular Scale:

{0:0}{0:f1}{0:c1}

Patterns can comprise plain text and a placeholder {0} with format specifiers. Use a colon to separate a placeholder and its format specifier.

In XAML, insert an escape sequence {} into the beginning of a pattern if it starts with the placeholder. For example: {}{0:0}.

Example

This example shows how to change the arc scale label format and behavior:

Use the following API members to customize labels:

MemberDescription
ArcScale.LabelOptionsGets or sets the options that specify the position and format for labels displayed on the scale.
ArcScaleLabelOptionsContains appearance and behavior options for arc scale labels.
ArcScaleLabelOptions.OrientationProvides different types of orientation for labels on the Circular scale.
ScaleLabelOptions.FormatStringGets or sets a value that specifies the format string for the display text on a scale.

The markup below configures a gauge that replicates the gauge appearance in the image above:

xaml
<Window x:Class="DXGauges_Circular.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxga="http://schemas.devexpress.com/winfx/2008/xaml/gauges"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxga:CircularGaugeControl Name="circularGaugeControl" 
                                   Margin="10">
            <dxga:CircularGaugeControl.Scales>
                <dxga:ArcScale StartValue="0" EndValue="12" 
                               StartAngle="-90" EndAngle="270"
                               MajorIntervalCount="12" MinorIntervalCount="5">
                    <dxga:ArcScale.LabelOptions>
                        <dxga:ArcScaleLabelOptions Orientation="LeftToRight"
                                                   FormatString="{}{0:f1}" 
                                                   ShowFirst="False"/>
                    </dxga:ArcScale.LabelOptions>
                    <dxga:ArcScale.Needles>
                        <dxga:ArcScaleNeedle Value="3">
                            <dxga:ArcScaleNeedle.Options>
                                <dxga:ArcScaleNeedleOptions EndOffset="65"/>
                            </dxga:ArcScaleNeedle.Options>
                        </dxga:ArcScaleNeedle>
                    </dxga:ArcScale.Needles>
                    <dxga:ArcScale.Layers>
                        <dxga:ArcScaleLayer/>
                    </dxga:ArcScale.Layers>
                </dxga:ArcScale>
            </dxga:CircularGaugeControl.Scales>
        </dxga:CircularGaugeControl>
    </Grid>
</Window>

See Also

ScaleLabelOptions Class

ScaleLabelOptions Members

DevExpress.Xpf.Gauges Namespace