Extended Library for WPF and Silverlight | ComponentOne
CoverFlow (Silverlight Only) / CoverFlow for Silverlight Quick Start / Step 4 of 5: Adding Code to the Project
In This Topic
    Step 4 of 5: Adding Code to the Project
    In This Topic
    In the last step, you added four items to the C1CoverFlow control and set the items’ properties. In this step, you’re going to create a C1CoverFlow.SelectedIndexChanged event handler and add code to the event handler that checks for the value of the C1CoverFlow.SelectedIndex property. The TextBlock control, which you added in Step 1 of 5: Creating the Project, will change its Text property string value when the user selects an album cover.

    Complete the following steps:

    1. In the Objects and Timeline panel, select C1CoverFlow1.
    2. In the Properties panel, click the Events button .
    3. Locate the C1CoverFlow.SelectedIndexChanged event handler and double-click inside its text box.

    The C1CoverFlow1_SelectedIndexChanged event handler is added to your project.

    Replace the code comment with the following code:

    Visual Basic
    Copy Code
    If C1CoverFlow1.SelectedIndex = 1 Then
       TextBlock1.Text = "Deep Purple: Machine Head"
      
    ElseIf C1CoverFlow1.SelectedIndex = 2 Then
       TextBlock1.Text = "Deep Purple: Made in Japan"
      
    ElseIf C1CoverFlow1.SelectedIndex = 3 Then
       TextBlock1.Text = "Deep Purple: Perfect Strangers"
    Else
    TextBlock1.Text = Nothing
    End If
    

    C#
    Copy Code
    if (C1CoverFlow1.SelectedIndex == 1)
    {
    TextBlock1.Text = "Deep Purple: Machine Head";
    }
                 
    else if (C1CoverFlow1.SelectedIndex == 2)
    {
    TextBlock1.Text = "Deep Purple: Made in Japan";
    }
                 
    else if (C1CoverFlow1.SelectedIndex == 3)
    {
    TextBlock1.Text = "Deep Purple: Perfect Strangers";
    }
                 
    else
    {
       TextBlock1.Text = null;
    }
    
          

    In this step, you added an event handler and code to your project. In the next step, you’ll run program and see the results of this quick start topic.