Questions tagged [wpf-controls]

WPF controls include UserControls, which are composite collections of other controls, and CustomControls, which are controls built with WPF styles and templates.

From Microsoft documentation:
Windows Presentation Foundation (WPF) ships with many of the common UI components that are used in almost every Windows application, such as Button, Label, TextBox, Menu, and ListBox. Historically, these objects have been referred to as controls. While the WPF SDK continues to use the term "control" to loosely mean any class that represents a visible object in an application, it is important to note that a class does not need to inherit from the Control class to have a visible presence. Classes that inherit from the Control class (AKA "Custom Controls") contain a ControlTemplate, which allows the consumer of a control to radically change the control's appearance without having to create a new subclass.

5697 questions
76
votes
7 answers

Custom vs User control

I've been reading some explanations about the difference between User and Custom Controls, for example this: http://www.wpftutorial.net/CustomVsUserControl.html I want to create, for example, a simple composition of a datagrid with 2 comboboxes…
Louro
  • 1,413
  • 4
  • 21
  • 27
75
votes
4 answers

Wpf control size to content?

How do I make a WPF control to change its size according the content in it?
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
69
votes
5 answers

'Graying Out' a WPF button image?

I have a simple Button control that contains an Image object as its content. I want so set the Image opacity to 0.5 when the Button is disabled to provide an additional visual cue as to the Button status. What is the simplest way to accomplish that…
David Veeneman
  • 18,912
  • 32
  • 122
  • 187
67
votes
4 answers

In WPF, how can I determine whether a control is visible to the user?

I'm displaying a very big tree with a lot of items in it. Each of these items shows information to the user through its associated UserControl control, and this information has to be updated every 250 milliseconds, which can be a very expensive task…
Trap
  • 12,050
  • 15
  • 55
  • 67
67
votes
7 answers

How to bind Close command to a button

The easiest way is to implement ButtonClick event handler and invoke Window.Close() method, but how doing this through a Command binding?
iLemming
  • 34,477
  • 60
  • 195
  • 309
65
votes
6 answers

C# how to get text value from PasswordBox?

I have a PasswordBox. how can I get the input value from the PasswordBox after the input has been finished?
5YrsLaterDBA
  • 33,370
  • 43
  • 136
  • 210
61
votes
4 answers

WPF ComboBox performance problems by binding a large collections

I'm trying to bind a large collection to a ComboBox and I faced performance problems when opening ComboBox's popup. I searched internet and found that using VirtualizingStackPanel as a items panel template might help, but it helped only partially.…
Alexey
  • 843
  • 1
  • 7
  • 9
59
votes
1 answer

How to add context menu to wpf datagrid?

How does one add a ContextMenu to a DataGrid? I want to be able to right click anywhere on the DataGrid.
StillWorking28269
  • 2,201
  • 2
  • 14
  • 6
56
votes
7 answers

AutoComplete TextBox in WPF

Is it possible to make a textbox autocomplete in WPF? I found a sample where a combo box is used and the triangle is removed by editing the style template. Is there a better solution?
Sharath
56
votes
6 answers

How to define TextBox input restrictions?

How can I restrict TextBox to accept only capital letters, or for example digits, or forbid to put any special character? Sure it's a piece of cake to catch TextInput event and handle the text here, but is it the proper way to do this?
iLemming
  • 34,477
  • 60
  • 195
  • 309
55
votes
5 answers

wpf datagrid alternate row coloring

I have tried this method.. without luck..