Convert Figma logo to code with AI

dotnet logowpf

WPF is a .NET Core UI framework for building Windows desktop applications.

7,228
1,190
7,228
1,460

Top Related Projects

27,472

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology

An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.

Quick Overview

The dotnet/wpf repository is the official open-source home for Windows Presentation Foundation (WPF), a UI framework for building Windows desktop applications. It provides a consistent programming model for building applications that separate the user interface from business logic, and supports a broad set of application development features.

Pros

  • Rich UI capabilities with extensive controls and customization options
  • XAML-based declarative UI design, allowing for separation of UI and logic
  • Powerful data binding and templating features
  • Supports modern .NET development and integration with other .NET technologies

Cons

  • Limited to Windows platform, not cross-platform
  • Steeper learning curve compared to some other UI frameworks
  • Can be resource-intensive for complex applications
  • Slower release cycle compared to some newer frameworks

Code Examples

  1. Creating a simple window with a button:
<Window x:Class="MyApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="My WPF App" Height="450" Width="800">
    <Grid>
        <Button Content="Click me!" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Button_Click"/>
    </Grid>
</Window>
  1. Implementing the button click event handler:
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("Button clicked!");
    }
}
  1. Data binding example:
<Window x:Class="MyApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Data Binding Example" Height="450" Width="800">
    <StackPanel>
        <TextBox x:Name="InputTextBox" Width="200" Margin="10"/>
        <TextBlock Text="{Binding ElementName=InputTextBox, Path=Text}" Margin="10"/>
    </StackPanel>
</Window>

Getting Started

  1. Install Visual Studio with the ".NET Desktop Development" workload.
  2. Create a new WPF App (.NET Core) project.
  3. Design your UI using XAML in the visual designer or code view.
  4. Implement your application logic in the code-behind files.
  5. Build and run your application using Visual Studio.

For more detailed instructions, refer to the official Microsoft documentation on getting started with WPF.

Competitor Comparisons

27,472

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology

Pros of Avalonia

  • Cross-platform support (Windows, macOS, Linux, iOS, Android, WebAssembly)
  • Modern, flexible architecture with MVVM pattern support
  • Active community and frequent updates

Cons of Avalonia

  • Smaller ecosystem and fewer third-party controls compared to WPF
  • Learning curve for developers familiar with WPF
  • Some advanced WPF features may not be available or implemented differently

Code Comparison

WPF XAML:

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="WPF Window" Height="450" Width="800">
    <Grid>
        <Button Content="Click me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Grid>
</Window>

Avalonia XAML:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="MainWindow"
        Title="Avalonia Window" Height="450" Width="800">
    <Grid>
        <Button Content="Click me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Grid>
</Window>

The code comparison shows that Avalonia's XAML syntax is very similar to WPF, with minor differences in namespace declarations. This similarity allows for easier transition between the two frameworks for developers familiar with WPF.

An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.

Pros of ReactiveUI

  • Cross-platform support for various .NET frameworks (Xamarin, UWP, WPF, etc.)
  • Reactive programming model for better handling of asynchronous operations
  • Extensive community support and active development

Cons of ReactiveUI

  • Steeper learning curve due to reactive programming concepts
  • Potentially more complex codebase for simple applications
  • May require additional libraries for full functionality

Code Comparison

WPF (XAML):

<Button Content="Click Me" Click="Button_Click"/>

ReactiveUI:

this.WhenAnyValue(x => x.ViewModel.ClickCommand)
    .BindTo(this, x => x.MyButton.Command);

ReactiveUI promotes a more declarative approach to UI interactions, while WPF uses traditional event-driven programming. ReactiveUI's code tends to be more concise but may require a deeper understanding of reactive concepts.

ReactiveUI offers greater flexibility across platforms and better handling of complex, asynchronous scenarios. However, WPF might be more suitable for simpler Windows-only applications or developers more comfortable with traditional .NET patterns.

The choice between these frameworks depends on project requirements, team expertise, and the desired application architecture.

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.

Pros of Xamarin.Forms

  • Cross-platform development for iOS, Android, and Windows
  • Single codebase for multiple platforms, reducing development time
  • Native UI performance through platform-specific renderers

Cons of Xamarin.Forms

  • Limited access to platform-specific features without custom renderers
  • Steeper learning curve for developers new to mobile development
  • Larger app size compared to native applications

Code Comparison

Xamarin.Forms (XAML):

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
    <StackLayout>
        <Label Text="Hello, Xamarin.Forms!" />
        <Button Text="Click me" Clicked="OnButtonClicked" />
    </StackLayout>
</ContentPage>

WPF (XAML):

<Window x:Class="WpfApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel>
        <TextBlock Text="Hello, WPF!" />
        <Button Content="Click me" Click="OnButtonClick" />
    </StackPanel>
</Window>

Both frameworks use XAML for UI design, but Xamarin.Forms focuses on cross-platform compatibility, while WPF is specific to Windows desktop applications. Xamarin.Forms uses platform-agnostic controls, whereas WPF utilizes Windows-specific controls and features.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Windows Presentation Foundation (WPF)

.NET Foundation Build Status codecov MIT License

Windows Presentation Foundation (WPF) is a UI framework for building Windows desktop applications.

WPF supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding and documents. WPF uses the Extensible Application Markup Language (XAML) to provide a declarative model for application programming.

WPF's rendering is vector-based, which enables applications to look great on high DPI monitors, as they can be infinitely scaled. WPF also includes a flexible hosting model, which makes it straightforward to host a video in a button, for example.

Visual Studio's designer, as well as Visual Studio Blend, make it easy to build WPF applications, with drag-and-drop and/or direct editing of XAML markup.

As of .NET 6.0, WPF supports ARM64.

See the WPF Roadmap to learn about project priorities, status and ship dates.

WinForms is another UI framework for building Windows desktop applications that is supported on .NET (7.0.x/6.0.x). WPF and WinForms applications only run on Windows. They are part of the Microsoft.NET.Sdk.WindowsDesktop SDK. You are recommended to use the most recent version of Visual Studio to develop WPF and WinForms applications for .NET.

To build the WPF repo and contribute features and fixes for .NET 8.0, Visual Studio 2022 Preview is required.

Getting started

Status

  • We are currently developing WPF for .NET 8.

See the WPF roadmap to learn about the schedule for specific WPF components.

Test published at separate repo Tests and have limited coverage at this time. We will add more tests, however, it will be a progressive process.

The Visual Studio WPF designer is now available as part of Visual Studio 2019.

How to Engage, Contribute and Provide Feedback

Some of the best ways to contribute are to try things out, file bugs, join in design conversations, and fix issues.

.NET Framework issues

Issues with .NET Framework, including WPF, should be filed on VS developer community, or Product Support. They should not be filed on this repo.

Relationship to .NET Framework

This code base is a fork of the WPF code in the .NET Framework. .NET Core 3.0 was released with a goal of WPF having parity with the .NET Framework version. Over time, the two implementations may diverge.

The Update on .NET Core 3.0 and .NET Framework 4.8 provides a good description of the forward-looking differences between .NET Core and .NET Framework.

This update states how going forward .NET Core is the future of .NET. and .NET Framework 4.8 will be the last major version of .NET Framework.

Code of Conduct

This project uses the .NET Foundation Code of Conduct to define expected conduct in our community. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a project maintainer at conduct@dotnetfoundation.org.

Reporting security issues and security bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

Also see info about related Microsoft .NET Core and ASP.NET Core Bug Bounty Program.

License

.NET Core (including the WPF repo) is licensed under the MIT license.

.NET Foundation

.NET Core WPF is a .NET Foundation project.

See the .NET home repo to find other .NET-related projects.