Uploaded on Sep 11, 2019
Windows Presentation Foundation (WPF) allows developers to easily build and create visually enriched UI based applications. The classical UI elements or controls in other UI frameworks are also enhanced in WPF applications.
Controls Use in Windows Presentation Foundation (WPF)
iFour CCoonntrsoullstancy
https://www.ifourtechnolab.com/wpf-software-development
Controls
Windows Presentation Foundation (WPF) allows developers to easily build and create
visually enriched UI based applications.
The classical UI elements or controls in other UI frameworks are also enhanced in
WPF applications.
All of the standard WPF controls can be found in the Toolbox which is a part of the
System.Windows.Controls.
These controls can also be created in XAML markup language.
https://www.ifourtechnolab.com/wpf-software-development
Control Library
Grid Layout Building Blocks
Label ToolTip
Buttons Thumb
Editors Border
Lists Popup
Menus and toolbars Document Viewers
Scroll Viewer Frame
Ranges
Containers
https://www.ifourtechnolab.com/wpf-software-development
Grid Layout
Grid
Column Definition
Row Definition
Grid Lines
https://www.ifourtechnolab.com/wpf-software-development
Labels
The Label control, in its most simple form, will look very much like the TextBlock which
we used in another article. You will quickly notice though that instead of a Text property,
the Label has a Content property. The reason for that is that the Label can host any kind
of control directly inside of it, instead of just text.
https://www.ifourtechnolab.com/wpf-software-development
Buttons
https://www.ifourtechnolab.com/wpf-software-development
Editors
PasswordBox
TextBox
RichTextBox
InkCanvas
https://www.ifourtechnolab.com/wpf-software-development
List
Four standard list controls- ListBox, ComboBox, ListView, TreeView.
List controls can be filled from one of the two sources.
1. Items Property
2. ItemsSource Property.
https://www.ifourtechnolab.com/wpf-software-development
List View
List view derives from listBox
It has ability to separate view properties from control properties.
View property must be changed to grid view ad set properties on that object.
https://www.ifourtechnolab.com/wpf-software-development
Tree view
https://www.ifourtechnolab.com/wpf-software-development
New Lists using Templates
https://www.ifourtechnolab.com/wpf-software-development
Menus & ToolBars
https://www.ifourtechnolab.com/wpf-software-development
Expander
Expander is a layout in which we can add
We can assign the expand direction either
https://www.ifourtechnolab.com/wpf-software-development
Dialog
Standalone applications typically have a main window that both displays the main data over which the application operates and
exposes the functionality to process that data through user interface (UI) mechanisms like menu bars, tool bars, and status bars. A
non-trivial application may also display additional windows to do the following:
Display specific information to users.
Gather information from users.
Both display and gather information.
These types of windows are known as dialog boxes, and there are two types: modal and modeless.
https://www.ifourtechnolab.com/wpf-software-development
A modal dialog box is displayed by a function when the A modeless dialog box, on the other hand, does not prevent
function needs additional data from a user to continue. a user from activating other windows while it is open.
Because the function depends on the modal dialog box to For example, if a user wants to find occurrences of a
gather data particular word in a document, a main window will often
the modal dialog box also prevents a user from activating open a dialog box to ask a user what word they are looking
other windows in the application while it remains open. for.
In most cases, a modal dialog box allows a user to signal Since finding a word doesn't prevent a user from editing the
when they have finished with the modal dialog box by document, however, the dialog box doesn't need to be
pressing either an OK or Cancel button. modal.
Pressing the OK button indicates that a user has entered A modeless dialog box at least provides a Close button to
data and wants the function to continue processing with that close the dialog box.
data.
Pressing the Cancel button indicates that a user wants to
stop the function from executing altogether
https://www.ifourtechnolab.com/wpf-software-development
Dialog-Message box
A message box is a dialog box that can be used to display textual information and to allow users to make
decisions with buttons.
To create a message box, you use the MessageBox class. MessageBox lets you configure the message box
text, title, icon, and buttons, using code like the following.
The following figure shows a message box that displays textual information, asks a question, and provides
the user with three buttons to answer the question.
string messageBoxText = "Do you want to save
changes?";
string caption = "Word Processor";
MessageBoxButton button =
MessageBoxButton.YesNoCancel;
MessageBoxImage icon = MessageBoxImage.Warning;
// Display message box
MessageBox.Show(messageBoxText, caption, button, icon);
https://www.ifourtechnolab.com/wpf-software-development
Message box(cont..)
// Display message box
MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon);
// Process message box results
switch (result)
{
case MessageBoxResult.Yes:
// User pressed Yes button
break;
case MessageBoxResult.No:
// User pressed No button
// ...
break;
case MessageBoxResult.Cancel:
// User pressed Cancel button
// ...
break;
}
https://www.ifourtechnolab.com/wpf-software-development
Other Common Dialog Boxes are
Open File Dialog
Save File Dialog Box
Print Dialog Box
A modeless dialog box, such as the Find Dialog A modeless dialog box is opened by calling the Show
Box shown in the following figure, has the same
method.
fundamental appearance as the modal dialog
box. Unlike ShowDialog, Show returns immediately.
Consequently, the calling window cannot tell when the
modeless dialog box is closed and, therefore, does not
Screenshot that shows a Find dialog box. know when to check for a dialog box result or get data
from the dialog box for further processing.
However, the behavior is slightly different, as Instead, the dialog box needs to create an alternative
described in the following sections. way to return data to the calling window for
processing.
https://www.ifourtechnolab.com/wpf-software-development
Window
and manage the lifetime of windows and dialog
boxes.
When you create a new WPF project, then by default,
the Window control is present.
https://www.ifourtechnolab.com/wpf-software-development
Context Menu
A context menu, often referred to as a popup or pop-up menu, is a menu which is shown upon certain user actions,
usually a right-click with the mouse on a specific control or window.
Contextual menus are often used to offer functionality that's relevant within a single control.
https://www.ifourtechnolab.com/wpf-software-development
https://www.ifourtechnolab.com/wpf-software-development
Third-party controls
Third-party controls are those which are not created
by Microsoft but are created by some individual or
company by using WPF User Control or Custom
Control. Telerik and DevExpress are the most popular
companies for creating third-party controls.
https://www.ifourtechnolab.com/wpf-software-development
https://www.ifourtechnolab.com/wpf-software-development
Calendar
⚫ Calendar is a control that enables a user to select a date by using a visual calendar
display.
⚫ It provides some basic navigation using either the mouse or keyboard
https://www.ifourtechnolab.com/wpf-software-development
Cont.….
https://www.ifourtechnolab.com/wpf-software-development
Date picker
⚫ A Date Picker is a control that allows a user to pick a date value.
⚫ The user picks the date by using Combo Box selection for month, day, and year
values
https://www.ifourtechnolab.com/wpf-software-development
Cont.….
Properties
Date Gets or sets the date currently set in the date
picker.
DayFormat Gets or sets the display format for the day value.
DayFormatProperty Gets the identifier for the DayFormat
dependency property.
Orientation Gets or sets a value that indicates whether the
day, month, and year selectors are stacked
horizontally or vertically.
YearFormat Gets or sets the display format for the year
value.
MonthFormat Gets or sets the display format for the month
value.
https://www.ifourtechnolab.com/wpf-software-development
Image
⚫ A control that displays an image, you can use either the Image object or the Image
Brush object.
⚫ An Image object display an image, while an Image Brush object paints another
object with an image.
https://www.ifourtechnolab.com/wpf-software-development
Cont.….
Properties
wSource Gets or sets the source for the image.
Width Gets or sets the width of a FrameworkElement.
(Inherited from FrameworkElement)
StretchProperty Identifies the Stretch dependency property.
Opacity Gets or sets the degree of the object's opacity.
(Inherited from UIElement)
Name Gets or sets the identifying name of the object.
CanDrag Gets or sets a value that indicates whether the
element can be dragged as data in a drag-and-
drop operation. (Inherited from UIElement)
https://www.ifourtechnolab.com/wpf-software-development
Popup
⚫ Popup is a control that displays content on top of existing content, within the
bounds of the application window.
⚫ It is a temporary display on other content.
https://www.ifourtechnolab.com/wpf-software-development
Cont.….
Properties
Child Gets or sets the content to be hosted in the
popup.
ChildProperty Gets the identifier for the Child dependency
property.
IsOpen Gets or sets whether the popup is currently
displayed on the screen.
Opacity Gets or sets the degree of the object's opacity.
(Inherited from UIElement)
Name Gets or sets the identifying name of the object.
https://www.ifourtechnolab.com/wpf-software-development
Progress Bar
⚫ Progress Bar is a control that indicates the progress of an operation, where the
typical visual appearance is a bar that animates a filled area as the progress
continues.
It can show the progress in one of the two following styles −
⚫ A bar that displays a repeating pattern, or
⚫ A bar that fills based on a value.
https://www.ifourtechnolab.com/wpf-software-development
Cont.….
Properties
IsIndeterminate Gets or sets a value that indicates whether the
progress bar reports generic progress with a
repeating pattern or reports progress based on
the Value property.
ShowError Gets or sets a value that indicates whether the
progress bar should use visual states that
communicate an Error state to the user.
ShowPaused Gets or sets a value that indicates whether the
progress bar should use visual states that
communicate a Paused state to the user.
Name Gets or sets the identifying name of the object.
https://www.ifourtechnolab.com/wpf-software-development
Scroll Viewer
⚫ A ScrollViewer is a control that provides a scrollable area that can contain other
visible elements.
https://www.ifourtechnolab.com/wpf-software-development
Cont.….
Properties
ComputedHorizontalScrollBarVisibility Gets a value that indicates whether the
horizontal ScrollBar is visible.
ComputedHorizontalScrollBarVisibilityProper Identifies the
ty ComputedHorizontalScrollBarVisibility
dependency property.
ScrollableHeight Gets a value that represents the vertical size of
the area that can be scrolled; the difference
between the width of the extent and the width of
the viewport.
Name Gets or sets the identifying name of the object.
ScrollableWidth Gets a value that represents the horizontal size
of the area that can be scrolled; the difference
between the width of the extent and the width of
the viewport.
https://www.ifourtechnolab.com/wpf-software-development
Toggle Button
⚫ A Toggle Button is a control that can switch states, such as CheckBox and
RadioButton. .
https://www.ifourtechnolab.com/wpf-software-development
Cont.….
Properties
IsChecked Gets or sets whether the ToggleButton is
checked.
IsCheckedProperty Identifies the IsChecked dependency property.
IsThreeState Gets or sets a value that indicates whether the
control supports three states
Name Gets or sets the identifying name of the object.
IsThreeStateProperty Identifies the IsThreeState dependency property.
https://www.ifourtechnolab.com/wpf-software-development
tooltip
⚫ A tooltip is a control that creates a pop-up window that displays information for
an element in the GUI.
https://www.ifourtechnolab.com/wpf-software-development
Cont.….
Properties
IsOpen Gets or sets a value that indicates whether the
ToolTip is visible.
Placement Gets or sets how a ToolTip is positioned in
relation to the placement target element.
PlacementTarget Gets or sets the visual element or control that
the tool tip should be positioned in relation to
when opened by the ToolTipService.
Name Gets or sets the identifying name of the object.
https://www.ifourtechnolab.com/wpf-software-development
Comments