Back to Devexpress

Scale.CustomLabelsSource Property

wpf-devexpress-dot-xpf-dot-gauges-dot-scale-499a78a5.md

latest3.4 KB
Original Source

Scale.CustomLabelsSource Property

Gets or sets a source of custom labels.

Namespace : DevExpress.Xpf.Gauges

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

NuGet Package : DevExpress.Wpf.Gauges

Declaration

csharp
public IEnumerable CustomLabelsSource { get; set; }
vb
Public Property CustomLabelsSource As IEnumerable

Property Value

TypeDescription
IEnumerable

A source of custom labels.

|

Remarks

Use the CustomLabelTemplate property to specify a custom template that generates custom labels.

xaml
<Style TargetType="{x:Type dxga:ArcScale}">
    <Setter Property="CustomLabelsSource" Value="{Binding RomanLabels}"/>
    <Setter Property="CustomLabelTemplate">
        <Setter.Value>
            <DataTemplate>
                <dxga:ScaleCustomLabel Value="{Binding Hour}"
                                       Content="{Binding RomanHour}"
                                       Visible="{Binding Visible}"/>
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>
csharp
public class WorldTimeViewModel {
    public IEnumerable<HourLabelData> RomanLabels { get; private set; }
}

public class HourLabelData : BindableBase {
    public int Hour { get; private set; }
    public string RomanHour { get; private set; }
    public bool Visible {
        get { return GetProperty(() => Visible); }
        set { SetProperty(() => Visible, value); }
    }

    public HourLabelData(int hour) {
        Hour = hour;
        RomanHour = romanHours[hour - 1];
    }
    static string[] romanHours = 
        new string[] { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" };
}
vb
Public Class WorldTimeViewModel
    Public Property RomanLabels As IEnumerable(Of HourLabelData)
End Class

Public Class HourLabelData
    Inherits BindableBase

    Public Property Hour As Integer
    Public Property RomanHour As String

    Public Property Visible As Boolean
        Get
            Return GetProperty(Function() Visible)
        End Get
        Set(ByVal value As Boolean)
            SetProperty(Function() Visible, value)
        End Set
    End Property

    Public Sub New(ByVal hour As Integer)
        Hour = hour
        RomanHour = romanHours(hour - 1)
    End Sub

    Shared romanHours As String() = 
        New String() {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"}
End Class

Run Demo: Circular Scales

See Also

Scale Class

Scale Members

DevExpress.Xpf.Gauges Namespace