[]
        
(Showing Draft Content)

Step 3of 4- Adding- Code Application

In the previous steps you set up the application's user interface and added controls to your application. In this step you'll add code to your application to finalize it.


Complete the following steps:

WPF

  1. Double-click Window1 to switch to Code view and create the Window1_Loaded event handler.

  2. In Code view, add the following import statement to the top of the page:

Imports C1.WPF
using C1.WPF;
  1. In a WPF application, add code to the Window_Loaded event handler so that it appears like the following:

Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
    UpdateGradient()
End Sub
private void Window_Loaded(object sender, RoutedEventArgs e)
{
    UpdateGradient();
}
  1. Add the following code just after the Window1_Loaded event handler to update the gradient values:

Private Sub UpdateGradient()
    If IsLoaded Then
        Me.goldcol.Offset = Me.c1rs1.LowerValue
        Me.blackcol.Offset = Me.c1rs1.UpperValue
    End If
End Sub
UpdateGradient()
{
    if (IsLoaded)
    {
        this.goldcol.Offset = this.c1rs1.LowerValue;
        this.blackcol.Offset = this.c1rs1.UpperValue;
    }
}
  1. Return to Design view.

  2. Click once on the C1RangeSlider control to select it and then navigate to the Properties window.

  3. Click the lightning bolt Events icon at the top of the Properties window to view events.

  4. Double-click the LowerValueChanged event to switch to Code view and create the c1rs1_LowerValueChanged event handler. Return to Design view and repeat this step with the UpperValueChanged event to create the c1rs1_UpperValueChanged event handler.

  5. Add code to the c1rs1_LowerValueChanged event handler so that it appears like the following:

Private Sub c1rs1_LowerValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c1rs1.LowerValueChanged
    UpdateGradient()
End Sub
private void c1rs1_LowerValueChanged(object sender, EventArgs e)
{
    UpdateGradient();
}
  1. Add code to the c1rs1_UpperValueChanged event handler so that it appears like the following:

Private Sub c1rs1_UpperValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c1rs1.UpperValueChanged
    UpdateGradient()
End Sub
c1rs1_UpperValueChanged(object sender, EventArgs e)
{
    UpdateGradient();
}

In this step you completed adding code to your application. In the next step you'll run the application and observe run-time interactions.

Silverlight

  1. Select View | Code to switch to Code view.

  2. In Code view, add the following import statement to the top of the page:

Imports C1.Silverlight
using C1.Silverlight;
  1. Add the following code just after the page's constructor to update the gradient values:

Private Sub UpdateGradient()
    If c1rs1 IsNot Nothing Then
        Me.goldcol.Offset = Me.c1rs1.LowerValue
        Me.blackcol.Offset = Me.c1rs1.UpperValue
    End If
End Sub
UpdateGradient()
{
    if (c1rs1 != null)
    {
        this.goldcol.Offset = this.c1rs1.LowerValue;
        this.blackcol.Offset = this.c1rs1.UpperValue;
    }
}
  1. Return to Design view.

  2. Click once on the C1RangeSlider control to select it and then navigate to the Properties window.

  3. Click the lightning bolt Events icon at the top of the Properties window to view events.

  4. Double-click the LowerValueChanged event to switch to Code view and create the c1rs1_LowerValueChanged event handler. Return to Design view and repeat this step with the UpperValueChanged event to create the c1rs1_UpperValueChanged event handler.

  5. Add the c1rs1_LowerValueChanged event handler so that it appears like the following:

Private Sub c1rs1_LowerValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c1rs1.LowerValueChanged
    UpdateGradient()
End Sub
private void c1rs1_LowerValueChanged(object sender, EventArgs e)
{
    UpdateGradient();
}
  1. Add the c1rs1_UpperValueChanged event handler so that it appears like the following:

Private Sub c1rs1_UpperValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c1rs1.UpperValueChanged
    UpdateGradient()
End Sub
c1rs1_UpperValueChanged(object sender, EventArgs e)
{
    UpdateGradient();
}

In this step you completed adding code to your application. In the next step you'll run the application and observe run-time interactions.