Windows Development.
Windows Forms and WPF
Subjects:
Windows Program Components
User Interface Design
Two Sets of Controls
Windows Forms Controls
WPF Controls
Properties
Methods
Introduction
Microsoft Windows programs have certain standard features that are familiar to users and that users have come to expect. Users feel more comfortable with applications that use those features. They feel safer experimenting with the program, knowing how the features will act.
Note!
Menus
Use Standard Menu Items
Context Menus
Context menus appear when the user right-clicks an object in the user interface to provide commands that are appropriate for the object that the user clicked. They are called context menus because their commands make sense in the context of the item that is clicked. (They are also sometimes called pop-up menus.)
The user interface, in the industrial design field of human – machine interaction, is the space where interaction between humans and machines occurs.
Toolbars and Ribbons
Toolbars let users access the most commonly used commands without opening a menu or context menu. They should contain buttons representing the commands that users will need the most.
The ribbon used by recent versions of some Microsoft products such as Word, Access, Excel, WordPad, and Paint is a combination of a menu and a toolbar. Tabs across the top let you pick a category of tool much as upper-level menus do. When you click a tab, that category’s tools appear below it, much as the tools in a toolbox do.
Dialog Boxes
A dialog box, or dialog, is a form that is displayed to give information to the user or to get input from the user. Dialog boxes can be either modal or modeless.
User interface design
User interface design or user interface engineering is the design of websites, computers, appliances, machines, mobile communication devices, and software applications with the focus on the user's experience and interaction.
The goal of user interface design is to make the user's interaction as simple and efficient as possible, in terms of accomplishing user goals—what is often called user-centered design. Good user interface design facilitates finishing the task at hand without drawing unnecessary attention to itself. Graphic design may be utilized to support its usability. The design process must balance technical functionality and visual elements to create a system that is not only operational but also usable and adaptable to changing user needs.
Controls
A control is a program object that represents a visible feature in a Microsoft Windows program. The object includes features that let the program manage the control to make it do things (such as making a drop-down menu open) or change the control’s appearance (such as changing a label’s text or color).
Windows programs are made up of controls. Controls include labels, text boxes, menus, combo boxes, sliders, scroll bars, and everything else you see on a form. In fact, the form itself is a control.
In addition to controls, many programs have components. A component is similar to a control except it has no visible presence of its own on the form at run time. For example, a timer component allows the program to perform some task at regular intervals. (A clock program might use a timer to update its display every second to show the current time.)
Controls
Windows Forms applications use controls and graphical methods that have been around for years. In contrast, WPF controls use a newer graphical subsystem that has been available since the Microsoft .NET Framework version 3.0 and that is more closely integrated into the DirectX libraries that include high-performance graphics routines. That allows WPF controls to take better advantage of the computer’s graphics hardware, giving them a richer appearance and better performance. WPF provides many benefits, including the following:
More efficient use of graphics hardware;
Property binding to provide property animation;
Property inheritance to promote a consistent appearance; Styles to give controls a consistent appearance;
Templates to give controls new behaviors; A richer control-containment model;
Using Controls
Windows Forms Controls
WPF Controls
Just as Windows Forms has a set of controls, WPF does as well. Many of these are functionally similar to Windows Forms controls, but some are new, and many of the controls — even the common ones — are somewhat different, either in appearance, in functionality, or both.
Note! The thing you normally call a form in a Windows Forms program is called a window in a WPF application.
WPF Controls
Properties
Typically, programs interact with controls by using the controls’ properties, methods, and events.
Windows Forms Properties
Properties are attributes that determine a control’s appearance or behavior.
For example, a Label control’s Text property determines the text displayed by the control. For an example of a property determining a control’s behavior, the ListBox control’s Sorted property determines whether the control sorts its items.
WPF Control Properties
WPF Control Properties
WPF controls use brushes to determine their colors:
Methods
A method is a piece of code that you can call to make a control do something. A simple example is the TextBox control’s Clear method, which makes the control clear its contents. The exact syntax for calling these methods depends on the programming language you’re using.
Events
A third way that a program can interact with a control is by using events. An event is a mechanism that lets a control tell the program that something interesting has occurred. When something interesting occurs, a control raises the event. The program can catch or handle the event and take whatever action is appropriate. It might display new output to the user, start performing some task, or close the application. The code that processes the event is called an event handler.
Events
WPF controls support many of the same (or similar) events provided by Windows Forms controls.
Controls and components define a program’s user interface. In addition to a user interface, most programs have extensive code behind the scenes to provide the program’s functionality.
For example, a simple drawing program would need code to save and load files, change drawing tools, modify the current drawing, and ensure that changes are saved before closing.