DevExpress WPF入门教程:创建 .NET 5 应用程序入门指南

本教程介绍如何创建.NET 5 应用程序,将其配置为使用 DevExpress WPF控件,以及添加Spreadsheet控件。

    

先决条件
  • .NET 5
  • Visual Studio 2019 v16.3 或以上版本
创建一个新项目

打开 Visual Studio 2019 并创建一个新项目,选择DevExpress v21.1 WPF App Template Gallery模板。

DevExpress WPF入门教程:创建 .NET 5 应用程序入门指南02

指定项目名称和位置。

DevExpress WPF入门教程:创建 .NET 5 应用程序入门指南03

在DevExpress Template Gallery中,选择.Net Core平台、Blank Application模板和.NET 5.0版本。

DevExpress WPF入门教程:创建 .NET 5 应用程序入门指南04

在Solution Explorer中右键单击项目,然后选择Edit Project File。

DevExpress WPF入门教程:创建 .NET 5 应用程序入门指南05

将 UseWindowsForms 键设置为 true:

XAML

<PropertyGroup><OutputType>WinExe</OutputType><TargetFramework>net5.0-windows</TargetFramework><UseWPF>true</UseWPF><UseWindowsForms>true</UseWindowsForms></PropertyGroup>

注意:

许多 DevExpress 产品都有一个跨平台的核心部分,它依赖于 Windows Forms 程序集,因此建议将 UseWindowsForms 标志设置为 true。

添加主题

1. 跳转到Tools | NuGet Package Manager | Manage NuGet Packages for Solution

2. 在“Browse”标签中,搜索“WindowsDesktop.Wpf.Themes”关键字并为当前项目安装 DevExpress.WindowsDesktop.Wpf.Themes.All 包,接受许可协议。

DevExpress WPF入门教程:创建 .NET 5 应用程序入门指南06

3. 构建解决方案。

添加控件

1. 打开MainWindow.xaml。

2. 添加以下 DevExpress 命名空间引用:

XAML

xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"

3. 将Spreadsheet控件从Visual Studio 工具箱拖动到 XAML 代码,更改应用程序标记如下:

XAML

<dx:ThemedWindow x_Class="DxWPFNetCoreApp.MainWindow"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"xmlns:dxsps="http://schemas.devexpress.com/winfx/2008/xaml/spreadsheet"xmlns:local="clr-namespace:DxWPFNetCoreApp"Title="MainWindow" Height="450" Width="800"><Grid><dxsps:SpreadsheetControl CommandBarStyle="Ribbon" ShowFormulaBar="True"/></Grid></dx:ThemedWindow>

4. 构建并运行解决方案。


DevExpress技术交流群4:715863792      欢迎一起进群讨论

更多DevExpress线上公开课、中文教程资讯请上中文网获取

高端UI界面开发
标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年5月26日
下一篇 2021年5月26日

相关推荐

发表回复

登录后才能评论