ComponentOne Gauges for WPF and Silverlight
Gauges for WPF and Silverlight Task-Based Help / Adding Tick Marks to the Gauge
In This Topic
    Adding Tick Marks to the Gauge
    In This Topic

    You can add tick marks to the C1LinearGauge control through the Properties window, XAML, or through code. Although this topic sets the C1GaugeMark properties of the C1LinearGauge control, the same steps can be used to customize the C1GaugeMark of other controls.

    At Design Time

    To add tick marks to the C1LinearGauge control in the Properties window at design time, complete the following steps:

    1. Click the C1LinearGauge control once to select it.
    2. Navigate to the Properties window, and click the ellipsis button next to the Decorators item. The Decorators collection editor will open.
    3. Choose C1GaugeMark in the drop-down list in the top-left of the editor and click the Add button. A C1GaugeMark decorator will be added to the collection and will be selected.
    4. In the right-side properties pane, set the C1GaugeMark element's C1GaugeDecorator.Location to 1.1.
    5. Set the C1GaugeLabel element's C1GaugeLabel.Interval to 20.
    6. Choose C1GaugeMark in the drop-down list in the top-left of the editor and click the Add button. A second C1GaugeMark decorator will be added to the collection and will be selected.
    7. In the right-side properties pane, set the C1GaugeMark element's Location to 1.1.
    8. Set the C1GaugeLabel element's Interval to 10.
    9. Choose C1GaugeMark in the drop-down list in the top-left of the editor and click the Add button. A third C1GaugeMark decorator will be added to the collection and will be selected.
    10. In the right-side properties pane, set the C1GaugeMark element's Location to 1.1.
    11. Set the C1GaugeLabel element's Interval to 5.

    In XAML

    To add labeling to the C1LinearGauge control in XAML add three <c1:C1GaugeMark> tags to the <c1:C1LinearGauge> tag so that it appears similar to the following:

    XAML
    Copy Code
    <c1:C1LinearGauge Height="89" Margin="90,72,41,88" Name="C1LinearGauge1" Width="287">
        <c1:C1GaugeMark Interval="20" Location="1.1" />
        <c1:C1GaugeMark Interval="10" Location="1.1" />
        <c1:C1GaugeMark Interval="5" Location="1.1" />
    </c1:C1LinearGauge>
    

     

    In Code

    Right-click the window and click View Code to switch to the Code Editor. And add code to the Window1_Loaded event handler or main class, so it appears similar to the following:

    Visual Basic
    Copy Code
    Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        Dim c1gm1 As New C1.WPF.Gauge.C1GaugeMark
        c1gm1.Location = 1.1
        c1gm1.Interval = 20
        Me.C1LinearGauge1.Decorators.Add(c1gm1)
        Dim c1gm2 As New C1.WPF.Gauge.C1GaugeMark
        c1gm2.Location = 1.1
        c1gm2.Interval = 10
        Me.C1LinearGauge1.Decorators.Add(c1gm2)
        Dim c1gm3 As New C1.WPF.Gauge.C1GaugeMark
        c1gm3.Location = 1.1
        c1gm3.Interval = 5
        Me.C1LinearGauge1.Decorators.Add(c1gm3)
    End Sub
    
    Public Sub New()
    InitializeComponent()
        Dim c1gm1 As New C1.WPF.Gauge.C1GaugeMark
        c1gm1.Location = 1.1
        c1gm1.Interval = 20
        Me.C1LinearGauge1.Decorators.Add(c1gm1)
        Dim c1gm2 As New C1.WPF.Gauge.C1GaugeMark
        c1gm2.Location = 1.1
        c1gm2.Interval = 10
        Me.C1LinearGauge1.Decorators.Add(c1gm2)
        Dim c1gm3 As New C1.WPF.Gauge.C1GaugeMark
        c1gm3.Location = 1.1
        c1gm3.Interval = 5
        Me.C1LinearGauge1.Decorators.Add(c1gm3)
    End Sub
    

     

    C#
    Copy Code
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        C1.WPF.Gauge.C1GaugeLabel c1gm1 = new C1.WPF.Gauge.C1GaugeMark();
        c1gm1.Location = 1.1;
        c1gm1.Interval = 20;
        this.c1LinearGauge1.Decorators.Add(c1gm1);
        C1.WPF.Gauge.C1GaugeLabel c1gm2 = new C1.WPF.Gauge.C1GaugeMark();
        c1gm2.Location = 1.1;
        c1gm2.Interval = 10;
        this.c1LinearGauge1.Decorators.Add(c1gm2);
        C1.WPF.Gauge.C1GaugeLabel c1gm3 = new C1.WPF.Gauge.C1GaugeMark();
        c1gm3.Location = 1.1;
        c1gm3.Interval = 5;
        this.c1LinearGauge1.Decorators.Add(c1gm3);
    }
    
    public MainPage(){
    InitializeComponent();
    {
        C1.WPF.Gauge.C1GaugeLabel c1gm1 = new C1. C1.WPF.Gauge.C1GaugeMark();
        c1gm1.Location = 1.1;
        c1gm1.Interval = 20;
        this.c1LinearGauge1.Decorators.Add(c1gm1);
        C1.WPF.Gauge.C1GaugeLabel c1gm2 = new C1.WPF.Gauge.C1GaugeMark();
        c1gm2.Location = 1.1;
        c1gm2.Interval = 10;
        this.c1LinearGauge1.Decorators.Add(c1gm2);
        C1.WPF.Gauge.C1GaugeLabel c1gm3 = new C1.WPF.Gauge.C1GaugeMark();
        c1gm3.Location = 1.1;
        c1gm3.Interval = 5;
        this.c1LinearGauge1.Decorators.Add(c1gm3);
    }
    

     

    Run your project and observe:

    The C1LinearGauge control will appear with tick marks of three sizes: