250 likes | 603 Views
Introducing WPF’s controls. - Santosh Singh. 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)
E N D
Introducing WPF’s controls - Santosh Singh
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 • Content controls are simply controls that are constrained to contain a single item. • Content controls all derive from System.Windows.Controls.ContentControl • The built-in content controls come in three major varieties: · Buttons · Simple containers · Containers with a header
Buttons • Buttons are probably the most familiar and essential user interface element • This behavior is actually captured by an abstract class called ButtonBase • The most interesting feature of ButtonBase, however, is its ClickMode property • This can be set to a value of a ClickMode enumeration to control exactly when the Click event gets raised. • Its values are Release (the default), Press, and Hover
Button Types • Button - Cancel button or a default button • RepeatButton - RepeatButton 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 RepeatButton's Delay and Interval properties. • ToggleButton - ToggleButton is a "sticky" button that holds its state when it is clicked.
Button Types • CheckBox 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 • RadioButton – RadioButton is another control that derives from ToggleButton, but is unique because it has built-in support for mutual exclusion. Checking one RadioButton automatically unchecks all others in the same group.
Simple Containers • Label 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. • ToolTip The ToolTip control holds its content in a floating box that appears when you hover over an associated control and disappears when you move the mouse away
Simple Containers • WPF ToolTip can hold anything you want!
Simple Containers ToolTip defines Open and Closed events in case you want to act upon its appearance and disappearance <CheckBox> CheckBox <CheckBox.ToolTip> <StackPanel> <Label FontWeight="Bold" Background="Blue" Foreground="White"> The CheckBox </Label> <TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200"> CheckBox is a familiar control. But in WPF, it's not much more than a ToggleButton styled differently! </TextBlock> <Line Stroke="Black" StrokeThickness="1" X2="200"/> <StackPanel Orientation="Horizontal"> <Image Margin="2" Source="help.gif"/> <Label FontWeight="Bold">Press F1 for more help.</Label> </StackPanel> </StackPanel> </CheckBox.ToolTip> </CheckBox>
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. • You can think of the Frame control as a more powerful version of the "Microsoft Web Browser“ ActiveX control or the Windows Forms WebBrowser control
Containers with a Header • GroupBox GroupBox is a familiar control for organizing chunks of controls. The Header property can be set to an arbitrary object. • Expander - Expander is very much like GroupBox, but contains a button that enables you to expand and collapse the inner content.
Selectors • Selectors are items controls whose items can be indexed and selected. • Selector also supports two attached properties that can be applied to individual items: • · IsSelected— A Boolean that can be used to select or unselect an item (or to retrieve its current selection state) • · IsSelectionActive— A read-only Boolean that tells you if the selection has focus
Selectors • There are four selector driven controls – • ComboBox
Selectors <ComboBox> <StackPanel Orientation="Horizontal" Margin="5"> <Image Source="CurtainCall.bmp"/> <StackPanel Width="200"> <TextBlock Margin="5,0" FontSize="14" FontWeight="Bold" VerticalAlignment="center">Curtain Call</TextBlock> <TextBlock Margin="5" VerticalAlignment="center" TextWrapping="Wrap"> Whimsical, with a red curtain background that represents a stage. </TextBlock></StackPanel></StackPanel> <StackPanel Orientation="Horizontal" Margin="5"> <Image Source="Fireworks.bmp"/> <StackPanel Width="200"> <TextBlock Margin="5,0" FontSize="14" FontWeight="Bold" VerticalAlignment="center">Fireworks</TextBlock> <TextBlock Margin="5" VerticalAlignment="center" TextWrapping="Wrap">Sleek, with a black sky containing fireworks. When you need tocelebrate PowerPoint-style, this design is for you! </TextBlock></StackPanel></StackPanel></ComboBox>
Selectors • ListBox
Selectors • ListView – The ListView control, which derives from ListBox, looks and acts just like a ListBox, except that it uses the Extended SelectionMode by default. But ListView also adds a property called View that enables you to customize the view in a richer way than choosing a custom ItemsPanel
Selectors <ListView> <ListView.View> <GridView> <GridViewColumn Header="Date"/> <GridViewColumn Header="Day of Week" DisplayMemberBinding="{Binding DayOfWeek}"/> <GridViewColumn Header="Year" DisplayMemberBinding="{Binding Year}"/> </GridView> </ListView.View> <sys:DateTime>1/1/2007</sys:DateTime> <sys:DateTime>1/2/2007</sys:DateTime> <sys:DateTime>1/3/2007</sys:DateTime> </ListView>
Selectors • TabControl The final selector—TabControl—is useful for switching between multiple pages of content. <TabControl> <TextBlock>Content for Tab 1.</TextBlock> <TextBlock>Content for Tab 2.</TextBlock> <TextBlock>Content for Tab 3.</TextBlock> </TabControl>
Menus • Menu simply stacks its items horizontally with the characteristic gray bar (by default) as its background <Menu> <MenuItem Header="_File"> <MenuItem Header="_New..."/> <MenuItem Header="_Open..."/> <Separator/> <MenuItem Header="Sen_d To"> <MenuItem Header="Mail Recipient"/> <MenuItem Header="My Documents"/> </MenuItem> </MenuItem> <MenuItem Header="_Edit"> </MenuItem> <MenuItem Header="_View"> </MenuItem></Menu>
Other Controls • TreeView • ToolBar
Other Controls • Status Bar • Progress Bar • Slider
Text and Ink Controls • WPF contains a handful of controls for displaying and editing text, whether typed with a keyboard or hand-written with a stylus. • TextBox • RichTextBox • PasswordBox • InkCanvas The amazing InkCanvas is a versatile element whose primary purpose is to capture handwriting
References • Windows Presentation Foundation Unleashed Author – Adam Nathan Publication - SAMS