Getting Started
- 3 minutes to read
This guide describes how to create a .NET Core 3 application, configure it to use DevExpress WPF controls, and add the Spreadsheet control.
Prerequisites
Create a New Project
Open Visual Studio 2019 v16.3 (or later) and create a new WPF Application (.NET Core).
Right-click the project in the Solution Explorer, and select Edit Project File.
Set the UseWindowsForms
key to true
:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>
Add DevExpress Controls to Your Application
Get DevExpress WPF Controls for .NET Core
Via NuGet
Go to Tools | NuGet Package Manager | Manage NuGet Packages for Solution
Open “Settings”…
… and add a new NuGet feed with the following credentials:
Name: DevExpress
Source: https://nuget.devexpress.com/{your feed authorization key}/apiSelect the DevExpress package source.
Via Installer
Download and install the Unified Installer for .NET Core 3 Desktop Development.
The installer creates a local NuGet feed with WPF controls for .NET Core.
- Go to Tools | NuGet Package Manager | Manage NuGet Packages for Solution
Select the DevExpress .NET Core Desktop 19.2 Local package source.
Add Controls to Your Application
In the “Browse” tab, search for the ‘WindowsDesktop.Wpf’ keyword and install the DevExpress.WindowsDesktop.Wpf and DevExpress.WindowsDesktop.Wpf.Themes.All packages for the current project. Accept the license agreement.
Build the solution.
After you have added the DevExpress.WindowsDesktop.Wpf and DevExpress.WindowsDesktop.Wpf.Themes.All packages for the current project, and built the solution, the DevExpress WPF controls for .NET Core will appear in the Visual Studio Toolbox.
Set an Application Theme
Set the ApplicationThemeHelper.ApplicationThemeName property to a theme name at the application startup.
public partial class App : Application {
protected override void OnStartup(StartupEventArgs e) {
DevExpress.Xpf.Core.ApplicationThemeHelper.ApplicationThemeName =
DevExpress.Xpf.Core.Theme.Office2019ColorfulName;
base.OnStartup(e);
}
}
Add a Control
Open MainWindow.xaml.
Add the following DevExpress namespace reference:
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
Change Window to the ThemedWindow,
<dx:ThemedWindow x:Class="DxWPFNetCoreApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:local="clr-namespace:DxWPFNetCoreApp" Title="MainWindow" Height="450" Width="800"> <Grid> </Grid> </dx:ThemedWindow>
… and in the code behind:
Drag the Spreadsheet control from the Visual Studio Toolbox to the XAML code. Change the application markup as follows:
<dx:ThemedWindow x:Class="DxWPFNetCoreApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 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>
Build and run the solution.