Friday, July 8, 2011

WPF Controls

WPF Controls are divided into three categories
  1. Content Controls
  2. Item Controls
  3. Layout Controls
Content Controls: They can contain single nested elements. This nested element can be of any type and can be set or retrieved in code through the Content property. The type of the Content property is Object, so it can accept any object as content. The following example code demonstrates how to render a button that has an image as its content:
 
<Button Margin="20,20,29,74" Name="button1">
        <Image Source="C:\Pictures\HumpbackWhale.jpg"/>
</Button>


Note that even though content controls can contain only a single nested element, there is no inherent limit on the number of nested elements that the content can contain. For example, it is possible for a content control to host a layout control that itself contains several additional UI elements.


Item controls: They can contain a list of nested elements. Item controls are designed to present multiple child items. Examples of item controls include ListBox, ComboBox, and TreeView as well as Menu, ToolBar, and StatusBar controls.

Layout controls: They are designed to host multiple controls and provide layout logic for those controls. Layout controls are containers that provide layout logic for contained controls. A layout control is typically the child element in a window. The Grid control is the most commonly used layout panel for the development of user interfaces. The Grid control enables you to define grid rows and columns and to host multiple elements in each cell. Layout panels such as UniformGrid, StackPanel, WrapPanel, DockPanel, and Canvas controls are commonly used to create specialized parts of the user interface.

Attached properties are properties provided to a control by its container or by another class. Examples of attached properties include the Grid.Row, Grid.Column, and KeyboardNavigation.TabIndex properties.

No comments:

Post a Comment