本教程將介紹執行哪些步驟才能在應用程序中添加Telerik UI for WPF控件。
本文主要向您展示如何在XAML中手動聲明命名空間。
幾乎所有Telerik控件都可以在“telerik”URI 命名空間架構中找到,您只能使用此命名空間來訪問在應用程序中引用的Telerik程序集中的所有控件,不能從未引用的程序集中訪問控件。
注意:很少有控件位於另一個命名空間中,例如RadPivotGrid 和 RadPivotFieldList,它們的命名空間是:xmlns:pivot="http://schemas.telerik.com/2008/xaml/presentation/pivot"。
1. 創建一個新的應用程序。
2. 在Solution Explorer中添加對Telerik DLL的引用。
- 打開 MainWindow.xaml。
- 跳轉到Window標記並添加以下命名空間。
Telerik 命名空間定義
XAML
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
或者從XAML中的IntelliSense中選擇它。
- 結果應該與此類似。
在XAML中添加Telerik 命名空間
XAML
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="350" Width="525"> <Grid> </Grid> </Window>
- 現在,您應該能夠聲明任何控件(存在於Telerik命名空間中),這些控件包含在添加到項目中的程序集中,RadTreeView 聲明的示例如下所示。
使用Telerik 命名空間
XAML
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="350" Width="525"> <Grid> <telerik:RadTreeView/> </Grid> </Window>
Telerik UI for WPF擁有超過100個控件來創建美觀、高性能的桌面應用程序,同時還能快速構建企業級辦公WPF應用程序。UI for WPF支持MVVM、觸摸等,創建的應用程序可靠且結構良好,非常容易維護,其直觀的API將無縫地集成Visual Studio工具箱中。