New .NET 9 WPF Features!

Exploring What’s New in WPF with .NET 9

Greetings to our developer community! In this article, let’s delve into the latest advancements in WPF with the release of .NET 9.I will focus on the new features, enhancements, and improvements that make developing your desktop applications more efficient and modern. We’ll also include a short section on how to style Xceed WPF controls using the Fluent Theme.

What’s New in WPF for .NET 9

So Fluent!

One of the most significant additions in .NET 9 for WPF is the introduction of the Fluent Theme. This theme brings the modern look and feel of the Fluent Design System to WPF applications, aligning them with the latest Windows UI guidelines.

Key features of the Fluent Theme:

      • Modernized Controls: Updated styles for standard controls like buttons, text boxes, sliders, and more.

      • Consistent Design Language: Provides a cohesive and modern appearance throughout the application.

      • High DPI Support: Improved rendering on high-resolution displays.

      • Accessibility Enhancements: Better support for assistive technologies.

    Applying the Fluent Theme

    To apply the Fluent theme to your WPF application, set the ApplicationTheme property in your App.xaml file:

    				
    					<Application x:Class="MyApp.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 ApplicationTheme="Fluent">
        <Application.Resources>
            <!-- Application resources -->
        </Application.Resources>
    </Application>
    				
    			

    Alternatively, you can merge the Fluent theme resource dictionary:

    				
    					<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Aero2;component/themes/FluentTheme.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
    				
    			

    Performance Improvements

    .NET 9 introduces several performance enhancements for WPF applications:

    • Optimized Rendering Pipeline: Reduces CPU and GPU usage for smoother visuals.
    • Improved Startup Time: Faster application launch.
    • Enhanced Data Binding: Reduced overhead in data binding operations.

    Accessibility and Localization Enhancements

    • Improved Screen Reader Support: Better UI Automation properties for controls.
    • Right-to-Left Support: Enhanced support for languages with right-to-left scripts.
    • High Contrast Themes: Better handling of high contrast settings for accessibility.

    Updated Tooling Support

    • XAML Hot Reload Enhancements: Faster and more reliable Hot Reload experience in Visual Studio.
    • Live Visual Tree Improvements: Easier debugging of the visual tree at runtime.

    What we learned…

    The release of .NET 9 brings significant enhancements to WPF, making it easier to create modern, high-performance desktop applications. The introduction of the Fluent Theme aligns WPF applications with the latest Windows UI design, providing a fresh and consistent user experience.

    We encourage you to explore these new features and consider updating your WPF applications to .NET 9 to take advantage of the improvements in performance, accessibility, and tooling support.

    Benefiting from Fluent Theme with Xceed Controls

    Styling the Xceed DataGrid with the Fluent Theme

    The good news is that at Xceed, we already have the Fluent Theme available for all of our WPF controls. Here’s a quick snippet you can use to style the DataGrid with the Fluent Theme : 

    				
    					  <xcdg:DataGridControl>
        <xcdg:DataGridControl.View>
          <xcdg:TableflowView>
            <xcdg:TableflowView.Theme>
              <xcdg:FluentDesignTheme>
                <xcdg:FluentDesignTheme.ThemeResourceDictionary>
                  <xcdg:FluentDesignResourceDictionary Mode="Light"
                                                       AccentColor="DarkOrange" />
                </xcdg:FluentDesignTheme.ThemeResourceDictionary>
              </xcdg:FluentDesignTheme>
            </xcdg:TableflowView.Theme>
          </xcdg:TableflowView>
        </xcdg:DataGridControl.View>
      </xcdg:DataGridControl>
        
    				
    			

    When it comes to the Xceed Toolkit for WPF, here’s how quick snippet of the xaml you can use : 

    				
    					<Application x:Class="Xceed.Wpf.Sales.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:local="clr-namespace:Xceed.Wpf.Sales"
                 xmlns:fdth="http://schemas.xceed.com/wpf/xaml/fluentui/design/themes"
                 xmlns:mdlb="http://schemas.xceed.com/wpf/xaml/listbox/themes"
                 xmlns:xcth="http://schemas.xceed.com/wpf/xaml/toolkit/themes"
                 StartupUri="MainWindow.xaml">
      <Application.Resources>
        <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
            <fdth:FluentDesignResourceDictionary AccentColor="Blue"
                                                 IsDark="True" />
            <mdlb:FluentDesignResourceDictionary />
            <xcth:FluentDesignResourceDictionary />
          </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
      </Application.Resources>
    </Application>
    				
    			

    There you have it! Xceed will keep updating all of their products and benefit from all the new .NET features in the future as well. We are working tightly with Microsoft so you can benefit from all these improvements.