ComponentOne Extended Library for WPF and Silverlight
Step 2 of 3: Adding Code to the Application
HtmlHost (Silverlight Only) > HtmlHost for Silverlight Quick Start > Step 2 of 3: Adding Code to the Application
In the last step you set up a Silverlight application, but if you run your application the button and text box currently do nothing. In this step you'll continue by adding code to add functionality to the application.

Complete the following steps:

  1. Navigate to the Solution Explorer, right-click MainPage.xaml file, and select View Code to switch to Code view.
  2. In Code view, add the following import statement to the top of the code page:

Visual Basic
Copy Code
Imports C1.Silverlight.Extended
   

 

C#
Copy Code
using C1.Silverlight.Extended;

 

  1. Add the following event handler to the MainPage.xaml.cs file, below all the other methods in the MainPage class:

Visual Basic
Copy Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
    Me.C1HtmlHost1.SourceUri = New Uri(String.Format(TextBox1.Text))
End Sub

private void Button1_Click(object sender, RoutedEventArgs e)
{
    Cc1HtmlHost1.SourceUri = new Uri(string.Format(TextBox1.Text));
}

    
C#
Copy Code
Type your example code here. It will be automatically colorized when you switch to Preview or build the help system.

This code handles the button's Click event and customizes the C1HtmlHost control.

 What You've Accomplished

In this step you added code to add functionality to your application – now when a user enters a URL in the text box and clicks the button at run time, the C1HtmlHost control will display the selected Web site. In the next step you'll run your application and observe some of the run-time interactions possible with HtmlHost for Silverlight.