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

WPF datagrid empty row at bottom

I bind my datagrid using //fill datagrid public DataTable GameData { get { DataSet ds = new DataSet(); FileStream fs = new FileStream(IMDB.WebPage.Class.Config.XMLPath, FileMode.Open, FileAccess.Read); …
WtFudgE
  • 5,080
  • 7
  • 47
  • 59
220
votes
5 answers

Window vs Page vs UserControl for WPF navigation?

I am currently writing a desktop application, but I cannot seem to get my head around what to use when redirecting someone to a new section of the application. My options appear to be Window Page UserControl but I don't understand what the…
Steve
  • 2,227
  • 3
  • 16
  • 9
215
votes
22 answers

How to bind an enum to a combobox control in WPF?

I am trying to find a simple example where the enums are shown as is. All examples I have seen tries to add nice looking display strings but I don't want that complexity. Basically I have a class that holds all the properties that I bind, by first…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
213
votes
12 answers

WPF and initial focus

It seems that when a WPF application starts, nothing has focus. This is really weird. Every other framework I've used does just what you'd expect: puts initial focus on the first control in the tab order. But I've confirmed that it's WPF, not just…
Joe White
  • 94,807
  • 60
  • 220
  • 330
210
votes
11 answers

How do I space out the child elements of a StackPanel?

Given a StackPanel: Apple Banana Cherry What's the best way to space out the child elements so that there are…
GraemeF
  • 11,327
  • 5
  • 52
  • 76
209
votes
17 answers

There is no ListBox.SelectionMode="None", is there another way to disable selection in a listbox?

How do I disable selection in a ListBox?
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
207
votes
4 answers

Binding a WPF ComboBox to a custom list

I have a ComboBox that doesn't seem to update the SelectedItem/SelectedValue. The ComboBox ItemsSource is bound to a property on a ViewModel class that lists a bunch of RAS phonebook entries as a CollectionView. Then I've bound (at separate times)…
Geoff Bennett
  • 2,513
  • 2
  • 16
  • 13
206
votes
5 answers

Disable Visual Studio 2015 extra debug option

When I debug my application in Microsoft Visual Studio 2015 Update 2, and I open a custom wpf dialog I get some extra debugging options in a black square. See image blow. How do I disable that? This first icon says "Go To Live Visual Tree". The…
Daltons
  • 2,671
  • 2
  • 18
  • 24
205
votes
8 answers

Set background color of WPF Textbox in C# code

How can I change the background and foreground colors of a WPF Textbox programmatically in C#?
Sauron
  • 16,668
  • 41
  • 122
  • 174
204
votes
3 answers

wpf: how to show tooltip when button disabled by command?

I'm trying to show a tooltip regardless of a buttons state, but this does not seem to do the trick:
204
votes
2 answers

Open file dialog and select a file using WPF controls and C#

I have a TextBox named textbox1 and a Button named button1. When I click on button1 I want to browse my files to search only for image files (type jpg, png, bmp...). And when I select an image file and click Ok in the file dialog I want the file…
NoobMaster69
  • 2,291
  • 3
  • 18
  • 24
203
votes
5 answers

Passing an enum value as command parameter from XAML

I want to pass an enum value as command parameter in WPF, using something like this:
201
votes
12 answers

WPF chart controls

I am looking for a very simple WPF chart which should have a 2D graph and should have pan and zoom facilities .
Rakesh Agarwal
  • 3,009
  • 9
  • 33
  • 40
198
votes
3 answers

What is the difference between a User Control Library and a Custom Control Library?

I am just coming up to speed on WPF and would like to create a reusable WPF control. When I look at the options for creating projects in Visual Studio, I see "WPF User Control Library" and "WPF Custom Control Library". It's unclear to me what the…
17 of 26
  • 27,121
  • 13
  • 66
  • 85
198
votes
17 answers

WPF User Control Parent

I have a user control that I load into a MainWindow at runtime. I cannot get a handle on the containing window from the UserControl. I have tried this.Parent, but it's always null. Does anyone know how to get a handle to the containing window from…
donniefitz2
  • 2,003
  • 2
  • 13
  • 6