Xceed DataGrid for Silverlight Documentation
Creating Your First DataGrid Project

In order to use Xceed DataGrid for Silverlight in Visual Studio, Visual Studio 2010 and Silverlight 4 must be installed.

All the assemblies required to use Xceed DataGrid for Silverlight (see Table 1) were placed in the installation folder (by default, C:\Program Files\Xceed\Xceed DataGrid for Silverlight v#.#\Bin) by the installer and integrated into Visual Studio 2010. The next step is to create an application that uses your snazzy, newly installed component.

On 64-bit operation systems, the assemblies are installed in the Program Files (x86) folder rather than the Program Files folder.

Table 1: Xceed DataGrid for Silverlight assemblies

Assembly Namespace Description
Xceed.Silverlight.DataGrid.v#.#.dll Xceed.Silverlight.DataGrid Contains all the main classes and interfaces.
Xceed.Silverlight.DataGrid.Converters Contains all the converter classes.
Xceed.Silverlight.DataGrid.EasingFunctions Contains all the easing-function classes.
Xceed.Silverlight.Data.v#.#.dll Xceed.Silverlight.Data Contains all data-management related classes and interfaces.
Xceed.Silverlight.Data.RiaServices.v#.#.dll Xceed.Silverlight.Data Contains all data-management RIA-services related classes and interfaces.
Xceed.Silverlight.DataGrid.Themes.v#.#.dll Xceed.Silverlight.DataGrid.Themes Contains the theme resource dictionaries that can be used to style a grid and its elements.
Xceed.Silverlight.Controls.v#.#.dll Xceed.Silverlight.Controls Contains classes related to controls used by Xceed's Silverlight products.
Xceed.Silverlight.DragDrop Contains all the classes related to the drag and drop capabilities of Xceed's Silverlight products.

The Xceed RIA Extensions for Silverlight assembly is only required when using WCF RIA Services.
The Xceed DataGrid Themes for Silverlight assembly is only required when using the theme resource dictionaries.

Creating a New Project in Visual Studio

Begin by creating a new Silverlight application from the installed templates.

 

In the New Silverlight Application dialog that will subsequently be displayed, make sure that Silverlight 4 is selected. If you require the use of WCF RIA Services, make sure to check the Enable WCF RIA Services checkbox . 

Once the new project is created, the main control (i.e., DataGridControl) will be available in the toolbox and can be dragged onto the design surface. 

If you prefer, you can add the references to the appropriates assemblies manually by right-clicking on the main project and selecting the Add Reference... menu item, which will open the Add Reference dialog box in which you can select the assemblies from the .NET tab.

The Xceed RIA Extensions for Silverlight assembly is only required when using WCF RIA Services.
The Xceed DataGrid Themes for Silverlight assembly is only required when using the theme resource dictionaries.

Now that the assemblies have been added, the required namespaces, which are included within the schema context, must be mapped using the xmlns attribute...

xmlns:sldg="http://schemas.xceed.com/silverlight/xaml/datagrid"

... and the datagrid added to the page, window, or user control, like so:

By default, a grid will take all the room that it requires; therefore, if it is not given a size constraint, such as when it is placed in a StackPanel, and a large amount of data items are present, UI virtualization will be lost—resulting in a significant loss in performance. To preserve UI virtualization when a grid is in a StackPanel, the MaxWidth and MaxHeight properties (or Width and Height) must be used to constrain the grid. As an alternative, a DockPanel or Grid can be used as both impose size constraints on their child elements.
<UserControl x:Class="Xceed.Silverlight.Documentation.MainPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:sldg="http://schemas.xceed.com/silverlight/xaml/datagrid"
             x:Name="myPage">
    <Grid x:Name="LayoutRoot">
        <sldg:DataGridControl x:Name="niftyNewDataGridControl"/>                             
    </Grid>
</UserControl>
If the datagrid control was added to the design surface via the toolbox, the namespace mapping the datagrid will be automatically created and added by the designer.

The last step is to bind the grid to a data source. For the purposes of this example, we will bind the grid to a property on the main page named Orders, which is a WCF Data Services DataServiceQuery of Order objects.

Data refers to a static class that loads data from the DataServiceContext and exposes ObservableCollection<T> properties for non-virtualized tables and DataServiceQuery<T> properties for virtualized tables.
Public ReadOnly Property Orders As DataServiceQuery( Of Order )
   Get   
      Return Data.Orders
   End Get
End Property
public DataServiceQuery<Order> Orders
{
   get
   {
      return Data.Orders;
   }
}
<!-- The DataContext of the MainPage was set to itself, allowing for direct access to the 
       members of the MainPage, including the Orders property, which is defined above. -->
<sldg:DataGridControl x:Name="niftyNewDataGridControl"
                                     ItemsSource="{Binding Path=Orders}"/>                             

For more information and examples on providing data, refer to the Providing Data topic.

Licensing

In order to use Xceed DataGrid for Silverlight in your application, the LicenseKey property of the Licenser class must be set with a valid license key, before any other method of the component is called. If you use an invalid or expired license key, fail to license the control altogether, or license it in the wrong place in your code, an exception will be thrown at run time.

For more information on licensing, refer to the Licensing topic.

Send Feedback