Introducing WPFs controls Santosh Singh Introduction Highlight on

  • Slides: 24
Download presentation
Introducing WPF’s controls - Santosh Singh

Introducing WPF’s controls - Santosh Singh

Introduction Highlight on some of the major built in controls. · Content Controls ·

Introduction Highlight on some of the major built in controls. · Content Controls · Items Controls · Range Controls · Text and Ink Controls Standard themes · Aero (the default Windows Vista theme) · Luna (the default Windows XP theme) · Royale (the theme from Windows XP Media Center Edition 2005 and Windows XP Tablet PC Edition 2005) · Classic (the theme available in Windows 2000 and later)

Content Controls n n n Content controls are simply controls that are constrained to

Content Controls n n n Content controls are simply controls that are constrained to contain a single item. Content controls all derive from System. Windows. Controls. Content. Control The built-in content controls come in three major varieties: · Buttons · Simple containers · Containers with a header

Buttons n n n Buttons are probably the most familiar and essential user interface

Buttons n n n Buttons are probably the most familiar and essential user interface element This behavior is actually captured by an abstract class called Button. Base The most interesting feature of Button. Base, however, is its Click. Mode property This can be set to a value of a Click. Mode enumeration to control exactly when the Click event gets raised. Its values are Release (the default), Press, and Hover

Button Types n n n Button - Cancel button or a default button Repeat.

Button Types n n n Button - Cancel button or a default button Repeat. Button - Repeat. Button acts just like Button except that it continually raises the Click event as long as the button is being pressed. The frequency of the raised Click events depends on the values of Repeat. Button's Delay and Interval properties. Toggle. Button - Toggle. Button is a "sticky" button that holds its state when it is clicked.

Button Types n Check. Box It has a single piece of externally supplied content

Button Types n Check. Box It has a single piece of externally supplied content (so this doesn't count the standard check box). It has a notion of being clicked by mouse or keyboard. It retains a state of being checked or unchecked when clicked.

Button Types n Radio. Button – Radio. Button is another control that derives from

Button Types n Radio. Button – Radio. Button is another control that derives from Toggle. Button, but is unique because it has builtin support for mutual exclusion. Checking one Radio. Button automatically unchecks all others in the same group.

Simple Containers n Label is a classic control used to hold text. It can

Simple Containers n Label is a classic control used to hold text. It can hold arbitrary content in its Content property—a Button, a Menu, and so on. n Tool. Tip The Tool. Tip control holds its content in a floating box that appears when you hover an associated control and disappears when you move the mouse away

Simple Containers n WPF Tool. Tip can hold anything you want!

Simple Containers n WPF Tool. Tip can hold anything you want!

Simple Containers Tool. Tip defines Open and Closed events in case you want to

Simple Containers Tool. Tip defines Open and Closed events in case you want to act <Check. Box> upon its appearance and disappearance Check. Box <Check. Box. Tool. Tip> <Stack. Panel> <Label Font. Weight="Bold" Background="Blue" Foreground="White"> The Check. Box </Label> <Text. Block Padding="10" Text. Wrapping="Wrap. With. Overflow" Width="200"> Check. Box is a familiar control. But in WPF, it's not much more than a Toggle. Button styled differently! </Text. Block> <Line Stroke="Black" Stroke. Thickness="1" X 2="200"/> <Stack. Panel Orientation="Horizontal"> <Image Margin="2" Source="help. gif"/> <Label Font. Weight="Bold">Press F 1 for more help. </Label> </Stack. Panel> </Check. Box. Tool. Tip> </Check. Box>

Simple Containers The Frame control holds arbitrary content, just like all other content controls,

Simple Containers The Frame control holds arbitrary content, just like all other content controls, but it isolates the content from the rest of the UI. n You can think of the Frame control as a more powerful version of the "Microsoft Web Browser“ Active. X control or the Windows Forms Web. Browser control n

Containers with a Header Group. Box is a familiar control for organizing chunks of

Containers with a Header Group. Box is a familiar control for organizing chunks of controls. The Header property can be set to an arbitrary object. n Expander - Expander is very much like Group. Box, but contains a button that enables you to expand collapse the inner content. n

Selectors n n Selectors are items controls whose items can be indexed and selected.

Selectors n n Selectors are items controls whose items can be indexed and selected. Selector also supports two attached properties that can be applied to individual items: · Is. Selected— A Boolean that can be used to select or unselect an item (or to retrieve its current selection state) · Is. Selection. Active— A read-only Boolean that tells you if the selection has focus

Selectors n There are four selector driven controls – ¨ Combo. Box

Selectors n There are four selector driven controls – ¨ Combo. Box

Selectors <Combo. Box> <Stack. Panel Orientation="Horizontal" Margin="5"> <Image Source="Curtain. Call. bmp"/> <Stack. Panel Width="200">

Selectors <Combo. Box> <Stack. Panel Orientation="Horizontal" Margin="5"> <Image Source="Curtain. Call. bmp"/> <Stack. Panel Width="200"> <Text. Block Margin="5, 0" Font. Size="14" Font. Weight="Bold" Vertical. Alignment="center">Curtain Call</Text. Block> <Text. Block Margin="5" Vertical. Alignment="center" Text. Wrapping="Wrap"> Whimsical, with a red curtain background that represents a stage. </Text. Block></Stack. Panel> <Stack. Panel Orientation="Horizontal" Margin="5"> <Image Source="Fireworks. bmp"/> <Stack. Panel Width="200"> <Text. Block Margin="5, 0" Font. Size="14" Font. Weight="Bold" Vertical. Alignment="center">Fireworks</Text. Block> <Text. Block Margin="5" Vertical. Alignment="center" Text. Wrapping="Wrap">Sleek, with a black sky containing fireworks. When you need tocelebrate Power. Point-style, this design is for you! </Text. Block></Stack. Panel></Combo. Box>

Selectors n List. Box

Selectors n List. Box

Selectors n List. View – The List. View control, which derives from List. Box,

Selectors n List. View – The List. View control, which derives from List. Box, looks and acts just like a List. Box, except that it uses the Extended Selection. Mode by default. But List. View also adds a property called View that enables you to customize the view in a richer way than choosing a custom Items. Panel

Selectors <List. View> <Grid. View. Column Header="Date"/> <Grid. View. Column Header="Day of Week" Display.

Selectors <List. View> <Grid. View. Column Header="Date"/> <Grid. View. Column Header="Day of Week" Display. Member. Binding="{Binding Day. Of. Week}"/> <Grid. View. Column Header="Year" Display. Member. Binding="{Binding Year}"/> </Grid. View> </List. View> <sys: Date. Time>1/1/2007</sys: Date. Time> <sys: Date. Time>1/2/2007</sys: Date. Time> <sys: Date. Time>1/3/2007</sys: Date. Time> </List. View>

Selectors n Tab. Control The final selector—Tab. Control—is useful for switching between multiple pages

Selectors n Tab. Control The final selector—Tab. Control—is useful for switching between multiple pages of content. <Tab. Control> <Text. Block>Content for Tab 1. </Text. Block> <Text. Block>Content for Tab 2. </Text. Block> <Text. Block>Content for Tab 3. </Text. Block> </Tab. Control>

Menus n Menu simply stacks items horizontally with the characteristic gray bar (by default)

Menus n Menu simply stacks items horizontally with the characteristic gray bar (by default) as its background <Menu> <Menu. Item Header="_File"> <Menu. Item Header="_New. . . "/> <Menu. Item Header="_Open. . . "/> <Separator/> <Menu. Item Header="Sen_d To"> <Menu. Item Header="Mail Recipient"/> <Menu. Item Header="My Documents"/> </Menu. Item> <Menu. Item Header="_Edit"> </Menu. Item> <Menu. Item Header="_View"> </Menu. Item></Menu>

Other Controls n Tree. View n Tool. Bar

Other Controls n Tree. View n Tool. Bar

Other Controls Status Bar n Progress Bar n Slider n

Other Controls Status Bar n Progress Bar n Slider n

Text and Ink Controls n n n WPF contains a handful of controls for

Text and Ink Controls n n n WPF contains a handful of controls for displaying and editing text, whether typed with a keyboard or hand-written with a stylus. Text. Box Rich. Text. Box Password. Box Ink. Canvas The amazing Ink. Canvas is a versatile element whose primary purpose is to capture handwriting

References n Windows Presentation Foundation Unleashed Author – Adam Nathan Publication - SAMS

References n Windows Presentation Foundation Unleashed Author – Adam Nathan Publication - SAMS