Step 1 of 4: Creating an Application with a C1Chart Control

In this step, you'll begin in Visual Studio to create a Silverlight application using Chart for Silverlight.

Complete the following steps:

1.   In Visual Studio 2008, select File | New | Project.

2.   In the New Project dialog box, select a language in the left pane, and in the templates list select Silverlight Application. Enter a Name for your project and click OK. The New Silverlight Application dialog box will appear.

3.   Click OK to close the New Silverlight Application dialog box and create your project.

4.   In the XAML window of the project, resize the UserControl by changing DesignWidth="640" DesignHeight="480" to DesignWidth="Auto" DesignHeight="Auto" in the <UserControl> tag so that it appears similar to the following:

<UserControl x:Class="ChartSilverlight_Quick_Start.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d" d:DesignWidth="Auto" d:DesignHeight="Auto">

The UserControl will now resize to accommodate any content placed within it.

5.   In the XAML window of the project, place the cursor between the <Grid> and </Grid> tags and click once. Note that you cannot currently add Silverlight controls directly to the design area in Visual Studio, so you must add them to the XAML window as directed in the next step.

6.   Navigate to the Toolbox and double-click the C1Chart icon to add the control to the grid. The XAML markup resembles the following:

<Grid x:Name="LayoutRoot">

<c1chart:C1Chart></c1chart:C1Chart>

</Grid>

7.   Inside the Grid, initialize the C1Chart control and give it a name by adding x:Name=”c1Chart1” to the <c1chart:C1Chart> tag so that it appears similar to the following:

<c1chart:C1Chart Margin="0,0,8,8" MinHeight="160" MinWidth="240" Name="c1Chart1">

</c1chart:C1Chart>

The chart appears empty since we did not add the data for it yet.

What You’ve Accomplished

You've successfully created a Silverlight application containing a C1Chart control. In the next step, you will Step 2 of 4: Adding Data to the Chart, you will add the data for C1Chart.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.