Questions tagged [wpf]

Windows Presentation Foundation, or WPF, is a subsystem for rendering user interfaces in Windows-based applications.

Windows Presentation Foundation (WPF, previously known as “Avalon”) is part of the Microsoft .NET Framework used to create rich client user experiences for Windows applications. It is also considered as the successor to

It features a diverse set of controls, layout options, 2D and 3D graphics, media and text handling and enables data binding and style-driven templates.

It uses a combination of XAML, an XML-based markup language, and any of the Common Language Runtime languages to define user interface elements. A fundamental aspect of WPF is to separate the user interface definition from the business logic, which enables developers and designers to work concurrently on a single project much more easily. It enables the users to build a loosely coupled application with the use of data bindings effectively. WPF also moves UI rendering off to the video hardware through the use of . Doing so allows computers to utilize their GPU, which frees the CPU to handle more of the logic-oriented tasks.

WPF runtime libraries are included in all versions of Windows, since Windows Vista and Windows Server 2008.

To learn more, visit the WPF portal on MSDN. See also the Wikipedia entry on WPF.

WPF employs XAML, an XML-based language, to define and link various UI elements. WPF applications can also be deployed as standalone desktop programs, or hosted as an embedded object in a website. WPF aims to unify a number of common user interface elements, such as 2D/3D rendering, fixed and adaptive documents, typography, vector graphics, runtime animation, and pre-rendered media. These elements can then be linked and manipulated based on various events, user interactions, and data bindings.

Microsoft has released six major WPF versions:

  • WPF 4.6 (July 2015)
  • WPF 4.5 (August 2012)
  • WPF 4 (April 2010)
  • WPF 3.5SP1 (Aug 2008)
  • WPF 3.5 (Nov 2007)
  • WPF 3.0 (Nov 2006)

In future, the WPF runtime libraries will be provided by Microsoft as packages known as "App Local" in order for updates to be released independently of .NET Framework releases.

Breaking Changes

On December, 2018 WPF, WinForms and WinUI frameworks became another part of open source community, as announced by Microsoft. WinForms and WinUI are already open, and WPF is starting with System.XAML, and more changes will be announced during the 2019.

Resources

Visual Studio Extensions for WPF Controls

Chat Room

168897 questions
942
votes
109 answers

Metadata file '.dll' could not be found

I am working on a WPF, C# 3.0 project, and I get this error: Error 1 Metadata file 'WORK=- \Tools\VersionManagementSystem\BusinessLogicLayer\bin\Debug \BusinessLogicLayer.dll' could not be found C:\-=WORK=-…
Oliver
  • 35,233
  • 12
  • 66
  • 78
738
votes
39 answers

What is the correct way to create a single-instance WPF application?

Using C# and WPF under .NET (rather than Windows Forms or console), what is the correct way to create an application that can only be run as a single instance? I know it has something to do with some mythical thing called a mutex, rarely can I find…
Nidonocu
  • 12,476
  • 7
  • 42
  • 43
698
votes
20 answers

How do I get the color from a hexadecimal color code using .NET?

How can I get a color from a hexadecimal color code (e.g. #FFDFD991)? I am reading a file and am getting a hexadecimal color code. I need to create the corresponding System.Windows.Media.Color instance for the hexadecimal color code. Is there an…
viky
  • 17,275
  • 13
  • 71
  • 90
662
votes
15 answers

In WPF, what are the differences between the x:Name and Name attributes?

Sometimes it seems that the Name and x:Name attributes are interchangeable. So, what are the definitive differences between them, and when is it preferable to use one over the other? Are there any performance or memory implications to using them the…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
657
votes
14 answers

How do I use WPF bindings with RelativeSource?

How do I use RelativeSource with WPF bindings and what are the different use-cases?
David Schmitt
  • 58,259
  • 26
  • 121
  • 165
562
votes
19 answers

How do I exit a WPF application programmatically?

How is one supposed to exit an application such as when the user clicks on the Exit menu item from the File menu? I have tried: this.Dispose(); this.Exit(); Application.ShutDown(); Application.Exit(); Application.Dispose(); Among many others.…
anon271334
524
votes
8 answers

What's the difference between StaticResource and DynamicResource in WPF?

When using resources such as brushes, templates and styles in WPF, they can be specified either as StaticResources or as a DynamicResource
Isak Savo
  • 34,957
  • 11
  • 60
  • 92
484
votes
51 answers

The name 'InitializeComponent' does not exist in the current context

If I create a new project in Visual Studio 2010 SP1 and select "WPF Application" and tries to build the generated application, I get the error The name 'InitializeComponent' does not exist in the current context. I got a similar error this morning…
user876402
  • 4,849
  • 2
  • 15
  • 4
470
votes
11 answers

How to bind RadioButtons to an enum?

I've got an enum like this: public enum MyLovelyEnum { FirstSelection, TheOtherSelection, YetAnotherOne }; I got a property in my DataContext: public MyLovelyEnum VeryLovelyEnum { get; set; } And I got three RadioButtons in my WPF…
Sam
  • 28,421
  • 49
  • 167
  • 247
454
votes
11 answers

Storing WPF Image Resources

For a WPF application which will need 10 - 20 small icons and images for illustrative purposes, is storing these in the assembly as embedded resources the right way to go? If so, how do I specify in XAML that an Image control should load the image…
driis
  • 161,458
  • 45
  • 265
  • 341
439
votes
16 answers

How to bind inverse boolean properties in WPF?

What I have is an object that has an IsReadOnly property. If this property is true, I would like to set the IsEnabled property on a Button, ( for example ), to false. I would like to believe that I can do it as easily as IsEnabled="{Binding…
Russ
  • 12,312
  • 20
  • 59
  • 78
429
votes
15 answers

The calling thread cannot access this object because a different thread owns it

My code is as below public CountryStandards() { InitializeComponent(); try { FillPageControls(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Country Standards", MessageBoxButton.OK,…
Kuntady Nithesh
  • 11,371
  • 20
  • 63
  • 86
410
votes
33 answers

How do I get a TextBox to only accept numeric input in WPF?

I'm looking to accept digits and the decimal point, but no sign. I've looked at samples using the NumericUpDown control for Windows Forms, and this sample of a NumericUpDown custom control from Microsoft. But so far it seems like NumericUpDown…
Giffyguy
  • 20,378
  • 34
  • 97
  • 168
409
votes
5 answers

Difference between SelectedItem, SelectedValue and SelectedValuePath

What is the difference betweeen the following: SelectedItem SelectedValue SelectedValuePath All these dependency properties are defined in Selector class. I often confuse SelectedItem with SelectedValue , and SelectedValue with SelectedValuePath.…
Nawaz
  • 353,942
  • 115
  • 666
  • 851
408
votes
5 answers

Multiline for WPF TextBox

I am developing an app for sending some feedback. Basically I'm trying to make a TextBox for comments, but I'm used to the WinForms MultiLine=true. I've set MinLines to 3, which is getting there, but preferably I'd like it if the user is able to…
baron
  • 11,011
  • 20
  • 54
  • 88
1
2 3
99 100