O'Reilly logo

Programming C# 4.0 by Jesse Liberty, Matthew Adams, Ian Griffiths

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Elements and Controls

Some of the types used to construct a user interface are interactive elements with a distinctive behavior of their own, such as buttons, checkboxes, and listboxes. Although you need code to connect these elements to your application, they have some built-in interactive behavior: buttons light up when the mouse cursor moves over them and look pushed in when clicked; listboxes allow items to be selected; and so on. Other elements are more primitive. There are graphical shape elements and text elements, which are visible to the user but which don’t have an intrinsic behavior—if you want them to do more than simply be visible you need to write code to make that happen. And some elements don’t even appear directly; for example, there are layout elements that are often not visible themselves, as their job is to decide where other elements go.

You can tell what type of element you’re dealing with by looking at the corresponding .NET type’s base class. Most UI elements ultimately derive from FrameworkElement, but this class has some more specialized subtypes. Panel is the base class of layout elements. Shape is the base class of elements involving 2D graphical shapes. Control is the base class of elements that have some intrinsic interactive behavior of their own.

Note

This means that not all UI elements are controls. In fact, the majority of UI elements are not controls. Having said that, the term control is often used loosely—many authors, and even some parts of Microsoft’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required