Avaloniaui XPF Compatibility With WPF Datagrid
Overview
This demo showcases AvaloniaUI Compatibility with WPF DataGrid using the Avalonia-XPF (eXtensible Platform Framework) technology. The sample demonstrates how to use Syncfusion's WPF SfDataGrid control within an AvaloniaUI application, combining the power of AvaloniaUI's cross-platform capabilities with WPF's comprehensive control library.
About Avalonia-XPF-Compatibility
Avalonia-XPF is a compatibility layer that enables developers to use traditional WPF controls and frameworks within AvaloniaUI applications. It provides seamless integration between AvaloniaUI's modern, cross-platform architecture and the extensive ecosystem of WPF controls.
Key Benefits:
- Cross-Platform Support: Leverage WPF controls in AvaloniaUI applications
- Rich Component Library: Access to Syncfusion and other WPF control libraries
- Unified Development: Build applications using familiar WPF APIs with AvaloniaUI's framework
- Data Binding Integration: Seamless MVVM pattern support with data binding
Sample Features
This demo includes an Employee Data Grid with the following capabilities:
- Data Binding: MVVM pattern with employee data binding
- In-place Editing: Edit employee information directly in the grid
- Filtering & Sorting: Filter and sort employee records by any column
- Multiple Column Types: Text, template, checkbox, and percent columns
- Custom Templates: Display employee details with icons and formatted data
- Multi-row Selection: Select multiple employees using checkboxes
- Formatted Display: Currency formatting for salary and progress indicator for software proficiency
NuGet Configuration
To use Avalonia-XPF with Syncfusion WPF controls, configure your NuGet sources as follows:
Package Sources
The NuGet.config file should include the following package sources:
<configuration>
<packageSources>
<clear />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="xpf" value="https://xpf-nuget-feed.avaloniaui.net/v3/index.json" />
<add key="avalonia-nightly" value="https://nuget-feed-nightly.avaloniaui.net/v3/index.json" />
</packageSources>
</configuration>
Package Source Credentials
For accessing the XPF NuGet feed, provide authentication credentials:
<packageSourceCredentials>
<xpf>
<add key="Username" value="Enter the Username" />
<add key="ClearTextPassword" value="Enter the Password" />
</xpf>
</packageSourceCredentials>
Note: Replace Enter the Username and Enter the Password with your actual XPF feed credentials.
Project Setup
Prerequisites:
- .NET 7.0 or later
- Visual Studio 2022 or equivalent
- XPF SDK credentials for NuGet access
- Syncfusion License Key
Configuration Steps:
- Update NuGet.config: Ensure credentials are properly configured in the
NuGet.configfile located in the project root - Set License Key: Add your AvaloniaUI.Xpf.LicenseKey in the project file:
<RuntimeHostConfigurationOption Include="AvaloniaUI.Xpf.LicenseKey" Value="Your-License-Key" /> - Restore Packages: Run
dotnet restoreto download required packages - Build and Run: Build the solution and run the application
Usage
Once the application runs, the SfDataGrid displays employee data with full CRUD capabilities:
- Select employees using checkboxes
- Edit information by clicking on cells
- Filter data using the built-in filter row
- Sort by clicking column headers
- View formatted data with custom templates and visual indicators