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
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
DataContextproperty 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.
DataContextbinding 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
DataContextproperty in the WPF.
A class library that will act as the data layer for the application. This library will be called directly when the
DataContextproperty uses a data object to bind. If the
DataContextproperty 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 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:
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
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.
It is recommended that you download the MSI installer as shown in the following screenshot:
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
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
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 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:
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:
For VB.NET to C# comparison: http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
To convert C# to VB.NET: http://converter.telerik.com/
For the Model View ViewModel (MVVM) design pattern: http://vortexwolf.wordpress.com/2011/11/27/wpf-and-silverlight-design-patterns/
For object-oriented design overview: http://cplus.about.com/od/introductiontoprogramming/a/aboutoop.html
For WPF and
To download the SQL Server database and class libraries: http://www.packtpub.com/support
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.