ComponentOne Gauges for WPF and Silverlight
Silverlight Quick Start / Step 3 of 4: Adding Code to the Application
In This Topic
    Step 3 of 4: Adding Code to the Application
    In This Topic

    In the previous step you created a new Silverlight project and added Gauges for Silverlight controls to the application. In this step you'll add code to your application to customize it.

    Complete the following steps:

    1. Select View | Code to switch to Code view.
    2. Add the following imports statements to the top of the page:
      Visual Basic
      Copy Code
      Imports C1.Silverlight
      Imports C1.Silverlight.Gauge
      

      C#
      Copy Code
      using C1.Silverlight;
      using C1.Silverlight.Gauge;
      

       

    3. Add code for the TextBox_TextChanged event handler so that it appears like the following:
      Example Title
      Copy Code
      Private Sub tb1_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles tb1.TextChanged
          Me.c1lg1.Value = Me.tb1.Text
          Me.c1rg1.Value = Me.tb1.Text
          Me.c1kb1.Value = Me.tb1.Text
      End Sub
      

      C#
      Copy Code
      private void tb1_TextChanged(object sender, TextChangedEventArgs e)
      {
          this.c1lg1.Value = Convert.ToDouble(this.tb1.Text);
          this.c1rg1.Value = Convert.ToDouble(this.tb1.Text);
          this.c1kb1.Value = Convert.ToDouble(this.tb1.Text);
      }
      

      When a number is entered in the text box at run time, the value of the gauge controls will be set to that number.

    4. Add the code for the C1Knob_ValueChanged event handler to set the gauge and text box control values. It will look like the following:
      Visual Basic
      Copy Code
      Private Sub c1kb1_ValueChanged(ByVal sender As System.Object, ByVal e As C1.Silverlight.PropertyChangedEventArgs(Of System.Double)) Handles c1kb1.ValueChanged
          Me.c1lg1.Value = Me.c1kb1.Value
          Me.c1rg1.Value = Me.c1kb1.Value
          Me.tb1.Text = Me.c1kb1.Value.ToString
      End Sub
      

       

      C#
      Copy Code
      private void c1kb_ValueChanged(object sender, PropertyChangedEventArgs<double> e)
      {
          this.c1lg1.Value = this.c1kb1.Value;
          this.c1rg1.Value = this.c1kb1.Value;
          this.tb1.Text = Convert.ToString(this.c1kb1.Value);
      }
      

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