About this book

Telerik Reporting is a lightweight reporting solution for all .NET cloud, web, and desktop platforms (Azure, Silverlight, WPF, ASP.NET, and Windows Forms) which targets developers and end users alike. Rich interactive and reusable reports can be created by developers in Visual Studio and by end users in the desktop-based Report Designer.

This book will guide you through working with specific Telerik WPF controls as well as working with the database and other methods to load the controls. It will focus on four key technologies: the DataContext property of WPF, Telerik RadControls for WPF, XML serialization, and application security.

Starting with the basics, Telerik WPF Controls Tutorial will take you from the simple usage of a DataTable to serializing XML files into objects, covering a discussion of different types of security and validation for WPF windows along the way.

This book will start out by showing you the simple methods of populating Telerik RadControls using a DataTable. You will then move on to look at populating a generic list of objects from a database as well as serializing XML files into class objects. You will cover how to secure a WPF application using a simple database example as well as Active Directory to determine navigation control loading. You will then review using the Telerik API interface classes to load Gantt information. With this book, you will be guided through building an application with the addition of all the important controls along with provisions for data entry, layouts, editors, navigation, and scheduling.

This book will teach you the different aspects of the Telerik controls, from using the DataContext property to loading the controls using the Telerik API references. The book will also cover other WPF subjects such as security and WPF validation of the DataContext property.

Publication date:
February 2014
Publisher
Packt
Pages
124
ISBN
9781782176527

 

Chapter 1. Getting Started with Telerik RadControls

During my history as a developer and architect, I have always worked under the assumption that the controls in Visual Studio would be enough to develop any application. The reason I always worked with the common controls in Visual Studio was that these controls are updated automatically with the .NET framework the moment the version of the .NET framework is installed; so, there is never a problem of having to maintain the control version. Third-party controls can tend to be expensive, sometimes have a steep learning curve, and can be expensive to maintain throughout the life cycle of the application. When I needed more functionality, I extended the Visual Studio version of the control to meet the needs of the application. This approach works fine if the application is meant for a small audience such as an internal company application or small company application, where costs need to be contained as much as possible. This scenario needs to be decided by the developer in conjunction with the potential client.

If the plan for the application includes selling it to a wider audience, or if the application needs additional functionality without the extra work of extending each control, then using third party controls is a great way to cut the development time of the application while gaining additional functionality required in the application. Telerik RadControls can be a great option for this type of development. Telerik offers a large suite of .NET controls for WinForms, ASP.NET, and WPF.

This book will cover Telerik RadControls for WPF. RadControls can cut development time by 50 percent over the task of extending the existing Visual Studio standard controls, and since the controls are styled, the look and feel of the application will be enhanced by the use of RadControls.

This book expects that you already have experience with WPF and Visual Studio. You should also have some experience working with SQL Server and SQL. This experience will be helpful when deploying the database from the downloads in the book. The main focus of the book, along with RadControls, will be the use of object classes to bind a data object to the WPF controls. Here are the WPF concepts you should be familiar with in order to work with this book:

  • Object Oriented Design as well as the concept of the DataContext property in a WPF form. If you need to do a quick review of WPF and DataContext, you can review the following page at the http://msdn.microsoft.com/en-us/library/ms752347.aspx site. Also, if you are new to or lack the knowledge of object oriented design, review this website before starting on the book: http://cplus.about.com/od/introductiontoprogramming/a/aboutoop.htm.

  • DataContext binding information to support Telerik RadControls. These projects are available for download from the http://www.packtpub.com/support website along with the SQL Server database to support the following projects:

    • A class library that has object classes to support object data binding using the DataContext property in the WPF.

    • A class library that will act as the data layer for the application. This library will be called directly when the DataContext property uses a data object to bind. If the DataContext property uses an object from this class library, the class object will call the data layer.

Please make sure to download these files before reviewing the chapters in this book since the libraries are a major portion of the work with RadControls.

Telerik RadControls for WPF offer several different categories of RadControls for use within WPF:

  • Data Management: This category provides the editable options to display data from a data store, which include options such as a GridView and TreeListView

  • Data Visualization: This category provides the static options to display data, which include options such as a BarCode or Chart

  • Editors: This category provides the data entry options to gather input from the user, which include options such as a ComboBox or MaskedInput

  • Layouts: This category provides the display options such as a Book or TileList

  • Navigation: This category provides the options to create navigation in the application such as PanelBar or OutlookBar

  • Interactivity: This category provides the options to handle special media

  • Scheduling: This category provides the options to create scheduling information with Timeline and ScheduleView

  • Framework: This category provides the options for working with data with PersistenceFramework and EntityFrameworkDataSource

RadControls give the developer a great option to create a fully functional, well-styled, and full-featured application.

This book discusses the advantages of working with Telerik RadControls for WPF. The design of this book is a step-by-step methodology for working with selected Telerik controls. Each chapter discusses a different type of RadControl, such as Editors, and breaks down how to use the control in both bound and unbound methodologies.

The book will use C# as the language for the projects. We refer to VB.NET but the examples will be in C# only. If you are not familiar with C#, but still want to use the book, there is a great website for translating C# to VB.NET, which can be found at http://www.harding.edu/fmccown/vbnet_csharp_comparison.html. Telerik also has a site for handling the translation, which can be found at http://converter.telerik.com/. This site allows you to take a snippet of code and translate the code to VB.NET or C# depending on your preference.

Since this book is meant to be a tutorial for RadControls, we will stay away from selecting a design pattern for the use of the controls, and focus on the use of the controls. The choice of a design pattern should be based on the best option for the type of application you are developing within WPF. The options for using a pattern are discussed but we have decided to remove the discussion of design patterns. The Model View View Model (MVVM) pattern is the most commonly used design pattern for WPF applications. If you want to understand the pattern further, please review the following page:

http://msdn.microsoft.com/en-us/library/gg405484(v=pandp.40).aspx.

 

Prerequisites


The reader must have at least Visual Studio 2010 Express installed to take advantage of the book's examples. The projects that are referred to in the book are in the .NET framework 4.5 version. Please make sure to set the projects to the 4.0 or 4.5 framework, to ensure the best results. The example operating system is Windows 7 Ultimate, but these examples should run on Windows 7 or 8.

The sample projects in this book will use both, a SQL Server 2008 Express database and XML files, as data sources for the examples. The database and XML files will be included with the sample projects. The Telerik installation process will install the SQL Server as part of the complete installation. The book consists of projects to support the DataContext information in WPF. These projects, along with the database files, can be downloaded from Packt Publishing's website at http://www.packtpub.com/support.

The book will cover the 2013.2.0724 version of Telerik RadControls. At the time of the development of this book, this version was the latest version of RadControls.

At the time of writing this book, the current version of Telerik RadControls was Version 2013.2.0724.

The license for Telerik RadControls is a 30-day free trial license. The reader will not be able to create an installation of any application without purchasing the Telerik license.

 

Downloading the Telerik trial software


The first step to start using Telerik RadControls is to download the trial for WPF from the Telerik website. There are over 55 controls from Telerik with this license. The following is the link:

http://www.telerik.com/products/wpf/download.aspx

It is recommended that you download the MSI installer as shown in the following screenshot:

The download requires registration with Telerik to allow access to the MSI file. Fill in the information and the site will redirect you to the download page and begin to download the demo MSI file.

Once the file is downloaded you can start the installation. The Telerik installation will display the typical installation menu. Select the default installation making sure that you select your version of Visual Studio as part of the installation.

Once your version of Visual Studio has been selected, you can customize the location of the installation as you see fit. The installation will not take more than 10 minutes, but the process will require an Internet connection to verify the installation with the Telerik licensing site.

The next step is to do a simple verification to see whether the installation of the Telerik controls has been completed. The first step will be to create a new WPF project in Visual Studio 2012. Once the project has been created, the Telerik controls should display in the Visual Studio Toolbox as shown in the following screenshot:

If there is a problem with the installation and the controls are not displaying, you can right-click on the Toolbox, select Choose Toolbox items, and navigate to the Telerik installation to select the Telerik DLL libraries. If the Telerik libraries are not installed within the selected Telerik folder, contact the Telerik support site at http://www.telerik.com/support.aspx and enter a support ticket. Telerik does have very good technical support and will contact you with a ticket number for your issue.

Telerik also has an excellent blog for contacting Telerik support or other Telerik developers to discuss any issues that you may have as part of the development process. The Telerik blog is located at http://blogs.telerik.com/. The blog is broken down by the type of control or issue and can be very helpful when you develop a problem during your working process.

If you need more than those 30 days, which the Telerik trial license allows to work with RadControls, you can contact Telerik to extend the licensing. Telerik will often give you up to 90 days to allow for a full evaluation of RadControls.

 

Creating the first Telerik project


The next step in the installation process is to create a WPF project within Visual Studio to handle the final verification that the Telerik installation has been successful.

First, open Visual Studio by right-clicking on the desktop icon or start menu option and select Run as Administrator. This will allow you to access the registry during the creation of the WPF project. The Telerik installation needs to access the registry to set up the controls in the Toolbox.

Second, create a RadControls WPF/C# project in Visual Studio. To do this, create a new project, select C# as the language, and the .NET framework should be 4.5. Please refer to the following screenshot:

The Telerik project wizard should display in such a way that it allows you to select the controls you want to use within the project. This project will only require the Telerik.Windows.Controls and the Telerik.Windows.Controls.Input assemblies. If you do not see the Telerik project wizard, the installation is not correct. In this case, please uninstall the Telerik controls and retry the installation. If this problem persists, create a support ticket with Telerik at http://support.telerik.com.

Once the project has been created, open the MainWindow.xaml file in the designer within Visual Studio, then open the Toolbox and drag the RadMaskedEditTextInput control from the Telerik Input 2013 Q2 NET 45 option in the Toolbox. Once this control is dragged to the MainWindow.xaml (the Mask property should already be set to a20) run the project from the debugger. The project should build without an issue, and warn you that the Telerik controls are in demo mode.

Now that you have been able to create a project with Visual Studio and Telerik, the next step is to add the projects from the book's website to the solution for the WPF project. First, you right-click on the solution and select Add Project from the File menu option. Then, go to the location of the projects that you have downloaded from the Packt Publishing website at www.packtpub.com, and select the PacktPub data layer project. The namespace should be PackTPub.DataLayer. Arrange the hierarchy for the projects so that the PackTPub.DataLayer project should be highest in the compile list. The next project is the PackTPub.ObjectsLayer project, then the Telerik PackTPub.Windows.UI project. The solution should now look like the following screenshot:

There should be three projects in the solution. Once you have added the projects to the solution, make sure to rebuild the project and verify that the projects are complete. If there are any compile errors, please try to redownload the files and step through the process again. If these problems persist, please contact www.packtpub.com/support with the issue.

As a reminder, since the Telerik controls are demo versions, you will not be able to create an installation or deployment for these examples. The Telerik installation will not pass the licensing to the installation and the application will fail.

 

Telerik demo project


Telerik offers a complete Visual Studio project as a demo of all RadControls and how to use the controls within WPF. You can download the demo project and solution from the Telerik website at http://demos.telerik.com/wpf/.

Click on the Install button to download the Setup.exe file from the Telerik site. The installation process will also install SQL Server 2008 Express as noted in the previous section. Please make sure that your computer has enough space to install the SQL Server instance. If you already have SQL Server 2008 Express installed, select the launch link instead to bypass the demo project installation.

The demo installation will create the following icon on your desktop:

You can use this icon to launch the demo solution. This demo is executable and will display examples of each control within the WPF RadControl library. Each control will have an XAML and a C# example to illustrate how to use the control. The examples are often displayed using the MVVM design pattern, but the examples are still capable of displaying how to use each control even if you are not familiar with the MVVM pattern. Here is an example of how the demo is formatted:

Each XAML page displays a well-skinned page with the controls as an example. This page is an example of using a ComboBox to filter the data. There are a few points to review on this page:

  • On the upper-right corner, you will notice the Example and Code toggles. These toggles will allow you to view the code for the example displayed.

  • The More <control> Examples option allows you to review additional examples of the selected control by clicking on a drop-down list option of your choice.

  • The NEXT EXAMPLE button allows you to review each example one by one rather than trying to determine which example to review.

 

Summary


This chapter has demonstrated how to create a WPF project with the Telerik controls included within the Visual Studio Toolbox. Make sure that you have the capability to create a WPF project and add controls to a WPF form. The subsequent chapters rely on this functionality.

You should also have a complete Telerik solution with two supporting projects from the book downloads. This solution should be able to be built in Visual Studio without any compilation errors.

Please make sure to download the SQL Server database files, the supporting class libraries, and ensure that SQL Server has been installed. The subsequent chapters will rely on the capability to retrieve data from the SQL Server database to populate the controls and the class libraries to pass the information to the WPF application and the controls.

If you are light on experience with WPF, the concept of DataContext binding to an object, object-oriented design, or C# here is the list of the web links from the previous sections of the chapter for your review. Please make sure that you have a reasonable understanding of these concepts when you review the websites mentioned in the previous sections of this chapter. Here is the list of web links again for your review:

You should also be able to review the Telerik Demo project and review the examples from Telerik. Even though most of the examples use the MVVM design pattern, the examples can still be helpful in working with the controls not covered in this book.

Now that we have set up the projects for the book, let us discuss the topics in the next chapter. We will be covering the simple data entry controls available from Telerik, such as the RadAutoComplete and the RadMaskedEdit controls. We will also be looking at the RadSpellCheck feature within Telerik to allow us to check spelling within any text controls.

About the Author

  • Daniel R. Spalding

    Daniel R. Spalding is a software consultant who works with many companies in the Delaware Valley area of Pennsylvania. His software has been used by several companies as their primary source for running their businesses. He has consulted with several large firms on software architecture and product prototypes using Visual Studio and C#. He started his business in 1996, but worked for Bell Atlantic for the first 5 years of his career where he was in charge of the Lotus Notes Center of Excellence for Philadelphia.

    He has also been an adjunct professor for the last 19 years at both Drexel University and Peirce College working with students in all aspects of computing from software development to networking certification.

    Browse publications by this author

Latest Reviews

(1 reviews total)
Le contenu et les exemples sont très bonne.
Book Title
Unlock this full book FREE 10 day trial
Start Free Trial