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
250
votes
5 answers

ItemsControl with horizontal orientation

Do you know any controls inherited from the ItemsControl that have horizontal orientation of items?
user101375
  • 6,961
  • 9
  • 42
  • 43
248
votes
17 answers

Find all controls in WPF Window by type

I'm looking for a way to find all controls on Window by their type, for example: find all TextBoxes, find all controls implementing specific interface etc.
Andrija
  • 14,037
  • 18
  • 60
  • 87
245
votes
21 answers

How do I get an animated gif to work in WPF?

What control type should I use - Image, MediaElement, etc.?
ironpaw
  • 2,995
  • 3
  • 19
  • 10
243
votes
22 answers

MVVM: Tutorial from start to finish?

I'm a C#/Windows Forms programmer with more than 5 years experience. I've been investigating WPF using the MVVM (Model-View-ViewModel) design pattern. I have searched the Internet for tutorials. I have even watched the entirety of Jason Dolinger's…
JP Richardson
  • 38,609
  • 36
  • 119
  • 151
241
votes
20 answers

Bring a window to the front in WPF

How can I bring my WPF application to the front of the desktop? So far I've tried: SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true); SetWindowPos(new…
Factor Mystic
  • 26,279
  • 16
  • 79
  • 95
239
votes
5 answers

Window Height="Auto" not working as expected

What I am trying to do is show a window, that does not explicitly have a height/width, (both values omitted or set to Auto). I was guessing that the window would find out its size by auto - calculating all contained usercontrols sizes, but this…
Nikos Tsokos
  • 3,226
  • 2
  • 34
  • 41
239
votes
13 answers

What framework for MVVM should I use?

I am developing an application with the MVVM model, but I have reached a point where I need to choose which framework to use. Among the possible options are: MVVM Toolkit MVVM Foundation WPF Application Framework (WAF) Light MVVM Caliburn…
Rangel
  • 2,673
  • 4
  • 18
  • 11
237
votes
10 answers

Load a WPF BitmapImage from a System.Drawing.Bitmap

I have an instance of a System.Drawing.Bitmap and would like to make it available to my WPF app in the form of a System.Windows.Media.Imaging.BitmapImage. What would be the best approach for this?
Kevin
  • 9,309
  • 12
  • 44
  • 51
236
votes
5 answers

Task continuation on UI thread

Is there a 'standard' way to specify that a task continuation should run on the thread from which the initial task was created? Currently I have the code below - it is working but keeping track of the dispatcher and creating a second Action seems…
Greg Sansom
  • 20,442
  • 6
  • 58
  • 76
236
votes
3 answers

WPF Databinding: How do I access the "parent" data context?

I have a list (see below) contained in a window. The window's DataContext has two properties, Items and AllowItemCommand. How do I get the binding for the Hyperlink's Command property needs to resolve against the window's DataContext?
Jordan
  • 2,811
  • 2
  • 20
  • 21
233
votes
24 answers

How to hide close button in WPF window?

I'm writing a modal dialog in WPF. How do I set a WPF window to not have a close button? I'd still like for its WindowState to have a normal title bar. I found ResizeMode, WindowState, and WindowStyle, but none of those properties allow me to hide…
Michael Hedgpeth
  • 7,732
  • 10
  • 47
  • 66
233
votes
10 answers

The calling thread must be STA, because many UI components require this

I am using http://www.codeproject.com/KB/IP/Facebook_API.aspx I am trying to call the XAML which is created using WPF. But it gives me an error: The calling thread must be STA, because many UI components require this. I don't know what to do. I am…
C..
  • 6,897
  • 10
  • 30
  • 37
230
votes
4 answers

Setting design time DataContext on a Window is giving a compiler error?

I have the following XAML below for the main window in my WPF application, I am trying to set the design time d:DataContext below, which I can successfully do for all my various UserControls, but it gives me this error when I try to do it on the…
Jon Erickson
  • 112,242
  • 44
  • 136
  • 174
229
votes
6 answers

What's the difference between ContentControl and ContentPresenter?

I'm not sure when I should use ContentPresenter instead of ContentControl (and vice-versa). At the moment, I'm using ContentControl pretty much all the time in my DataTemplates. When would ContentPresenter be a better choice? and why?
Wilka
  • 28,701
  • 14
  • 75
  • 97
227
votes
7 answers

Difference between Control Template and DataTemplate in WPF

What is difference between a ControlTemplate and a DataTemplate in WPF?
Firoz
  • 7,224
  • 10
  • 41
  • 56