SlideShare a Scribd company logo
WPF Controls Basic WPF Controls Doncho Minkov Telerik School Academy schoolacademy.telerik.com   Technical Trainer http://www.minkov.it
Table of Contents WPF Controls Text controls Buttons List controls GroupBox  and  Expander Menus Toolbars
Table of Contents Other controls Slider  and  S croll  controls ProgressBar ToolTip Custom User Controls
WPF Controls
WPF Control WPF controls are typically not directly responsible for their own appearance The are all about behavior They defer to templates to provide their visuals
WPF Controls (2) Controls may use commands to represent supported operations Controls offer properties to provide a means of modifying either behavior Controls raise events when something important happens WPF provides a range of built-in controls Most of these correspond to standard Windows control types
Text  C ontrols
Label The purpose of the  Label  control is to provide a place to put a caption with an access key How does the  Label  know to which control it should redirect its access key? Target  property, indicating the intended target of the access key In the absence of this property, the  Label  control does nothing useful
Label Live Demo
TextBox
TextBox TextBox  is control for editing and displaying text By setting  AcceptsReturn  to true, it can edit multiple lines <TextBox Margin=&quot;5&quot; VerticalAlignment=&quot;Center&quot; Text=&quot;Single line textbox&quot; /> <TextBox AcceptsReturn=&quot;True&quot; Margin=&quot;5&quot; Height=&quot;50 VerticalScrollBarVisibility=&quot;Visible&quot; VerticalAlignment=&quot;Center&quot; Text=&quot;Multiline textbox&quot; /> <!--The result is-->
RichTextBox RichTextBox  supports all of the commands defined by the  EditingCommands  class R ecognize   the  RTF  format Paste formatted text from Internet Explorer and Word Both  TextBox  and  RichTextBox  offer built-in spellchecking SpellCheck.IsEnabled  attached property
RichTextBox Live Demo
Buttons
Button s Buttons are controls that a user can click An  XAML  attribute specifies the handler for the  Click  event Buttons derive from the common  ButtonBase  base class <Button Click=&quot;ButtonClicked&quot;>Click</Button> void ButtonClicked(object sender, RoutedEventArgs e) { MessageBox.Show(&quot;Button was clicked&quot;); } ButtonsWindow.xaml ButtonsWindow.xaml.cs
ToggleButton Holds its state when it is clicked IsChecked  property IsThreeState  property G ives  IsChecked  three possible values  true ,  false , or  null ToggleButton  defines a separate event for each  value of  IsChecked Checked  for  true Unchecked  for  false Indeterminate  for  null
ToggleButton Live Demo
CheckButton  and  RadioButton  They derive from  ButtonBase   indirectly via the  ToggleButton  class IsChecked  property, indicating whether the user has checked the button CheckBox  is nothing more than a  ToggleButton  with a different appearance Radio buttons are normally used in groups in which only one button may be selected  at a time
RadioButton  - Example Grouping radio buttons by name <StackPanel> <RadioButton GroupName=&quot;Fuel&quot; Margin=&quot;3&quot;>Petrol</RadioButton> <RadioButton GroupName=&quot;Fuel&quot; Margin=&quot;3&quot;>Diesel</RadioButton> <RadioButton GroupName=&quot;Induction&quot; Margin=&quot;3&quot;>Unforced</RadioButton> <RadioButton GroupName=&quot;Induction&quot; Margin=&quot;3&quot;>Mechanical supercharger</RadioButton> <RadioButton GroupName=&quot;Induction&quot; Margin=&quot;3&quot;>Turbocharger</RadioButton> </StackPanel>
RadioButton Live Demo
List  C ontrols
ComboBox  Enables users to select one item from a list ComboBox  defines two events DropDownOpened DropDownClosed ComboBox  can contain complex items
ComboBox Live Demo
ListView The  ListView  control derives from  ListBox It uses the  Extended   SelectionMode  by default View  property E nable  customize the view in a richer way The View property is of type  ViewBase , an abstract class
GridView GridView  class Has a  Columns  content property GridViewColumn  objects, as well as other properties to control the behavior of the  column headers Columns can be reordered by dragging and dropping them in the built application Columns can be resized Columns can automatically resize to &quot;just fit&quot;
ListView  and  GridView Live Demo
TreeView
TreeView Presents a hierarchical view Data with nodes that can be expanded and collapsed Important events: Expanded Collapsed Selected Unselected
TreeView Live Demo
GroupBox  and Expander
GroupBox  and Expander Both provide a container for arbitrary content and a place for a header on top Expander  can be expanded and collapsed GroupBox  always shows its content Both controls derive from  HeaderedContentControl We can place whatever content we like directly inside the control
GroupBox  and Expander Live Demo
Menus
Menu Menu  simply stacks its items horizontally <Menu Height=&quot;23&quot; VerticalAlignment=&quot;Top&quot; > <MenuItem Header=&quot;_File&quot;> <MenuItem Header=&quot;_New...&quot;/> <MenuItem Header=&quot;_Open...&quot;/> <Separator/> <MenuItem Header=&quot;Sen_d To&quot;> <MenuItem Header=&quot;Mail Recipient&quot;/> <MenuItem Header=&quot;My Documents&quot;/> </MenuItem> </MenuItem> <!--(the example continues)-->
Menu  (2) <MenuItem Header=&quot;_Edit&quot;> … </MenuItem> <MenuItem Header=&quot;_View&quot;> … </MenuItem> </Menu>  <!--  The result is  -->
MenuItem MenuItem  is a  headered  items control The  Header  is actually the main object MenuItem  contains many properties for customizing Icon IsCheckable InputGestureText Can handle events or  assign a command to  MenuItem ’s   Command  property
Menus Live Demo
ContextMenu Works just like  Menu It’s a simple container designed to hold  MenuItems  and  Separators Must attach it to a control via  ContextMenu  property When a user right-clicks on the control the context menu is displayed <ListBox> <ListBox.ContextMenu> <ContextMenu> … </ContextMenu> </ListBox.ContextMenu> … </ListBox>
Toolbars
Toolbars Toolbars provide faster access for frequently used operations WPF supports toolbars through the  ToolBarTray  and  ToolBar  controls StatusBar  behaves just like  Menu It’s typically used along the bottom of a  Window
Toolbars Live Demo
Other  C ontrols
Slider and Scroll Controls Allow a value to be selected from a range  They show a track, indicating the range and a  draggable  &quot;thumb&quot; The  ScrollBar  control is commonly used in conjunction with some scrolling viewable area Control the size of a scroll bar’s thumb with the  ViewportSize  property
Slider and Scroll Controls  (2) Slider  control is used to adjust values Slider  and  ScrollBar   have an  Orientation   property They both derive from a  common base class,  RangeBase Provides  Minimum  and  Maximum ,  SmallChange  and  LargeChange   properties
ProgressBar H elps  user  realize that  progress is indeed being made ProgressBar  has a default  Minimum  of 0 and a default  Maximum  of 100 IsIndeterminate   property True  -  ProgressBar  shows a generic animation Orientation  property Horizontal  by default
ToolTip Allows a floating label to be displayed above some part of the  user interface To associate a  ToolTip  with its target element set it as the  ToolTip  property of its  target <TextBox Width=&quot;147&quot; Height=&quot;25&quot;> <TextBox.ToolTip> <ToolTip Content=&quot;Type something here&quot; /> </TextBox.ToolTip>  <!--The result is--> </TextBox>
Creating Custom User Controls
How To Make  Custom User Control? From the Solution Explorer click  Add  –>  User Control After that it is like you are making a  Window After you finish the creation of the  UserControl   build the project Then you have your  UserControl   in the  Toolbox  menu
Adding Properties to  Custom User Control To add a  Property  in the  UserControl   you need a  DependencyProperty , e.g. public static readonly DependencyProperty SourceProperty; static ImageButton() { SourceProperty = DependencyProperty.Register( &quot;Source&quot;, typeof(ImageSource), typeof(ImageButton))); } public ImageSource Source { get { return (ImageSource)GetValue(SourceProperty); } set { SetValue(SourceProperty, value); } }
Adding Properties to  Custom User Control (2) To make the &quot; Source &quot; property work we have to use binding in the  Xaml   code For the binding we need to set the  x:Name   of the  UserControl Now in our  Window  we can set an image in our custom  ImageButton  control <Image Source=&quot;{Binding  ElementName= ImageButtonUserControl ,  Path=ImageSource }&quot;/> < my:ImageButton   ImageSource =&quot;Panda.png&quot;/>
Custom User Controls Live Demo
WPF Controls Questions?
Exercises Write a program that show the simple window with one  Tex t Box . Add text to the  Tex t Box.  If you select some text in the  TextBox   – display the current selection information. Write a program with a  Button  and a  Label . The label should show the number of clicks on the button. Write a program that visualize which one of the items collection are checked. Write a program that shows a  ComboBox  with various elements added to its Items. For example – add text, ellipse and picture.
Exercises (2) Write a program that  shows   ListView  with   columns that contain controls such as checkboxes and text boxes. The name of the columns are ID, Enabled, Value. Write a text editing user control that is like simple WordPad. It should have at least a  TextWrap  property,  Scrollbar ,  Buttons   for Save and Load,  ComboBoxes   for choosing  FontFamily   and  FontSize .
Exercises (3) Implement a specialized editor of text document libraries. A library is a number of text documents, organized as a tree in folders. In a folder there can be documents and other folders (as in Windows). Every document is some text with formatting. The editor must be able to create libraries, to open/save libraries, to read/write libraries from/to XML files. When a library is open the editor can edit the documents inside (changing the text and the formatting) and can create/delete/rename folders and documents. Use a  TreeView  for the folder tree and  RichTextBox  for the active document.
Exercises (4) The editor should have a  main menu, 2  context  menus (for  the folder tree and for the active document area), 3 tool bars (to open/save a library, to facilitate working with the folder tree and one for the active document), a status bar and appropriate shortcuts for the most frequently used

More Related Content

What's hot (20)

PPTX
Lab#1 - Front End Development
Walid Ashraf
 
PPT
Advanced Javascript
relay12
 
ODP
JavaScript and jQuery Fundamentals
BG Java EE Course
 
PPTX
Javascript dom
Muthuganesh S
 
PDF
JavaScript
Bharti Gupta
 
PPTX
Javascript functions
Alaref Abushaala
 
PDF
Web 5 | JavaScript Events
Mohammad Imam Hossain
 
DOCX
Java script basics
Thakur Amit Tomer
 
PPT
Learn javascript easy steps
prince Loffar
 
PDF
Javascript - Tutorial
adelaticleanu
 
PPTX
Application package
JAYAARC
 
PDF
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
PDF
Visual Basic(Vb) practical
Rahul juneja
 
PDF
Hibernate Mapping
InnovationM
 
PPTX
Lab #2: Introduction to Javascript
Walid Ashraf
 
PDF
Object Oriented PHP - PART-1
Jalpesh Vasa
 
PPS
Advisor Jumpstart: JavaScript
dominion
 
PPTX
DOM and Events
Julie Iskander
 
PDF
Javascript part1
Raghu nath
 
Lab#1 - Front End Development
Walid Ashraf
 
Advanced Javascript
relay12
 
JavaScript and jQuery Fundamentals
BG Java EE Course
 
Javascript dom
Muthuganesh S
 
JavaScript
Bharti Gupta
 
Javascript functions
Alaref Abushaala
 
Web 5 | JavaScript Events
Mohammad Imam Hossain
 
Java script basics
Thakur Amit Tomer
 
Learn javascript easy steps
prince Loffar
 
Javascript - Tutorial
adelaticleanu
 
Application package
JAYAARC
 
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
Visual Basic(Vb) practical
Rahul juneja
 
Hibernate Mapping
InnovationM
 
Lab #2: Introduction to Javascript
Walid Ashraf
 
Object Oriented PHP - PART-1
Jalpesh Vasa
 
Advisor Jumpstart: JavaScript
dominion
 
DOM and Events
Julie Iskander
 
Javascript part1
Raghu nath
 

Viewers also liked (14)

PPT
WPF Templating and Styling
Doncho Minkov
 
PPT
Slice and Dice
Doncho Minkov
 
PPT
CSS Presentation
Doncho Minkov
 
PPT
CSS 3
Doncho Minkov
 
PDF
Data Access with ADO.Net
Amitek Rathod
 
PDF
Web Design Concepts
Doncho Minkov
 
PPT
Model View ViewModel
Doncho Minkov
 
PPT
Web design Tools
Doncho Minkov
 
PPT
Simple Data Binding
Doncho Minkov
 
PPT
Ado.net
dina1985vlr
 
PPT
HTML 5
Doncho Minkov
 
PPT
ASP.NET 09 - ADO.NET
Randy Connolly
 
PPT
For Beginers - ADO.Net
Snehal Harawande
 
PPTX
ADO.NET -database connection
Anekwong Yoddumnern
 
WPF Templating and Styling
Doncho Minkov
 
Slice and Dice
Doncho Minkov
 
CSS Presentation
Doncho Minkov
 
CSS 3
Doncho Minkov
 
Data Access with ADO.Net
Amitek Rathod
 
Web Design Concepts
Doncho Minkov
 
Model View ViewModel
Doncho Minkov
 
Web design Tools
Doncho Minkov
 
Simple Data Binding
Doncho Minkov
 
Ado.net
dina1985vlr
 
HTML 5
Doncho Minkov
 
ASP.NET 09 - ADO.NET
Randy Connolly
 
For Beginers - ADO.Net
Snehal Harawande
 
ADO.NET -database connection
Anekwong Yoddumnern
 
Ad

Similar to WPF Controls (20)

PPT
2 Day - WPF Training by Adil Mughal
Adil Mughal
 
PDF
Wpf Introduction
Martha Rotter
 
PPTX
WPF Deep Dive
Aniruddha Chakrabarti
 
PPT
WPF Line of Business Control Templates Styles
Our Community Exchange LLC
 
PDF
Ch7.2-Controls for Programm 001-193819qk
romoeogonzales
 
PPT
WPF Applications, It's all about XAML these days
Dave Bost
 
PPTX
Vs c# lecture1
Saman M. Almufti
 
PDF
Winforms
Girmachew Tilahun
 
PPTX
Xaml programming
Senthamil Selvan
 
PDF
Visual Basic IDE Introduction
Ahllen Javier
 
PDF
Visual Basic IDE Intro.pdf
sheenmarie0212
 
PPTX
Windows form application_in_vb(vb.net --3 year)
Ankit Gupta
 
PPT
MSDN Unleashed: WPF Demystified
Dave Bost
 
PPTX
Meetup - Getting Started with MVVM Light for WPF - 11 may 2019
iFour Technolab Pvt. Ltd.
 
PPTX
WPF - An introduction
Sharada Gururaj
 
PPTX
Data Bondage in WPF
Bruce Johnson
 
PPT
WPF Fundamentals
Our Community Exchange LLC
 
PDF
Interactive material
Anoo Al-henai
 
PPTX
Visual Basic.pptx
KavithaAlagumalai
 
PPTX
Visual basic
KavithaAlagumalai
 
2 Day - WPF Training by Adil Mughal
Adil Mughal
 
Wpf Introduction
Martha Rotter
 
WPF Deep Dive
Aniruddha Chakrabarti
 
WPF Line of Business Control Templates Styles
Our Community Exchange LLC
 
Ch7.2-Controls for Programm 001-193819qk
romoeogonzales
 
WPF Applications, It's all about XAML these days
Dave Bost
 
Vs c# lecture1
Saman M. Almufti
 
Winforms
Girmachew Tilahun
 
Xaml programming
Senthamil Selvan
 
Visual Basic IDE Introduction
Ahllen Javier
 
Visual Basic IDE Intro.pdf
sheenmarie0212
 
Windows form application_in_vb(vb.net --3 year)
Ankit Gupta
 
MSDN Unleashed: WPF Demystified
Dave Bost
 
Meetup - Getting Started with MVVM Light for WPF - 11 may 2019
iFour Technolab Pvt. Ltd.
 
WPF - An introduction
Sharada Gururaj
 
Data Bondage in WPF
Bruce Johnson
 
WPF Fundamentals
Our Community Exchange LLC
 
Interactive material
Anoo Al-henai
 
Visual Basic.pptx
KavithaAlagumalai
 
Visual basic
KavithaAlagumalai
 
Ad

More from Doncho Minkov (18)

PPT
HTML 5 Tables and Forms
Doncho Minkov
 
PPT
CSS Overview
Doncho Minkov
 
PPT
CSS Layout
Doncho Minkov
 
PPT
Adobe Photoshop
Doncho Minkov
 
PPT
Introduction to XAML and WPF
Doncho Minkov
 
PPT
WPF Layout Containers
Doncho Minkov
 
PPT
WPF Graphics and Animations
Doncho Minkov
 
PPT
Introduction to Cross-platform Mobile Development Course
Doncho Minkov
 
PPT
HTML Fundamentals
Doncho Minkov
 
PPT
Tables and Forms in HTML
Doncho Minkov
 
PPT
HTML5
Doncho Minkov
 
PPT
CSS Part I
Doncho Minkov
 
PPT
CSS Part II
Doncho Minkov
 
PPT
CSS3
Doncho Minkov
 
PPT
Workshop Usability
Doncho Minkov
 
PPT
JavaScript
Doncho Minkov
 
PPT
JavaScript OOP
Doncho Minkov
 
PPT
jQuery Fundamentals
Doncho Minkov
 
HTML 5 Tables and Forms
Doncho Minkov
 
CSS Overview
Doncho Minkov
 
CSS Layout
Doncho Minkov
 
Adobe Photoshop
Doncho Minkov
 
Introduction to XAML and WPF
Doncho Minkov
 
WPF Layout Containers
Doncho Minkov
 
WPF Graphics and Animations
Doncho Minkov
 
Introduction to Cross-platform Mobile Development Course
Doncho Minkov
 
HTML Fundamentals
Doncho Minkov
 
Tables and Forms in HTML
Doncho Minkov
 
HTML5
Doncho Minkov
 
CSS Part I
Doncho Minkov
 
CSS Part II
Doncho Minkov
 
Workshop Usability
Doncho Minkov
 
JavaScript
Doncho Minkov
 
JavaScript OOP
Doncho Minkov
 
jQuery Fundamentals
Doncho Minkov
 

Recently uploaded (20)

PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Python basic programing language for automation
DanialHabibi2
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
July Patch Tuesday
Ivanti
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 

WPF Controls

  • 1. WPF Controls Basic WPF Controls Doncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer http://www.minkov.it
  • 2. Table of Contents WPF Controls Text controls Buttons List controls GroupBox and Expander Menus Toolbars
  • 3. Table of Contents Other controls Slider and S croll controls ProgressBar ToolTip Custom User Controls
  • 5. WPF Control WPF controls are typically not directly responsible for their own appearance The are all about behavior They defer to templates to provide their visuals
  • 6. WPF Controls (2) Controls may use commands to represent supported operations Controls offer properties to provide a means of modifying either behavior Controls raise events when something important happens WPF provides a range of built-in controls Most of these correspond to standard Windows control types
  • 7. Text C ontrols
  • 8. Label The purpose of the Label control is to provide a place to put a caption with an access key How does the Label know to which control it should redirect its access key? Target property, indicating the intended target of the access key In the absence of this property, the Label control does nothing useful
  • 11. TextBox TextBox is control for editing and displaying text By setting AcceptsReturn to true, it can edit multiple lines <TextBox Margin=&quot;5&quot; VerticalAlignment=&quot;Center&quot; Text=&quot;Single line textbox&quot; /> <TextBox AcceptsReturn=&quot;True&quot; Margin=&quot;5&quot; Height=&quot;50 VerticalScrollBarVisibility=&quot;Visible&quot; VerticalAlignment=&quot;Center&quot; Text=&quot;Multiline textbox&quot; /> <!--The result is-->
  • 12. RichTextBox RichTextBox supports all of the commands defined by the EditingCommands class R ecognize the RTF format Paste formatted text from Internet Explorer and Word Both TextBox and RichTextBox offer built-in spellchecking SpellCheck.IsEnabled attached property
  • 15. Button s Buttons are controls that a user can click An XAML attribute specifies the handler for the Click event Buttons derive from the common ButtonBase base class <Button Click=&quot;ButtonClicked&quot;>Click</Button> void ButtonClicked(object sender, RoutedEventArgs e) { MessageBox.Show(&quot;Button was clicked&quot;); } ButtonsWindow.xaml ButtonsWindow.xaml.cs
  • 16. ToggleButton Holds its state when it is clicked IsChecked property IsThreeState property G ives IsChecked three possible values true , false , or null ToggleButton defines a separate event for each value of IsChecked Checked for true Unchecked for false Indeterminate for null
  • 18. CheckButton and RadioButton They derive from ButtonBase indirectly via the ToggleButton class IsChecked property, indicating whether the user has checked the button CheckBox is nothing more than a ToggleButton with a different appearance Radio buttons are normally used in groups in which only one button may be selected at a time
  • 19. RadioButton - Example Grouping radio buttons by name <StackPanel> <RadioButton GroupName=&quot;Fuel&quot; Margin=&quot;3&quot;>Petrol</RadioButton> <RadioButton GroupName=&quot;Fuel&quot; Margin=&quot;3&quot;>Diesel</RadioButton> <RadioButton GroupName=&quot;Induction&quot; Margin=&quot;3&quot;>Unforced</RadioButton> <RadioButton GroupName=&quot;Induction&quot; Margin=&quot;3&quot;>Mechanical supercharger</RadioButton> <RadioButton GroupName=&quot;Induction&quot; Margin=&quot;3&quot;>Turbocharger</RadioButton> </StackPanel>
  • 21. List C ontrols
  • 22. ComboBox Enables users to select one item from a list ComboBox defines two events DropDownOpened DropDownClosed ComboBox can contain complex items
  • 24. ListView The ListView control derives from ListBox It uses the Extended SelectionMode by default View property E nable customize the view in a richer way The View property is of type ViewBase , an abstract class
  • 25. GridView GridView class Has a Columns content property GridViewColumn objects, as well as other properties to control the behavior of the column headers Columns can be reordered by dragging and dropping them in the built application Columns can be resized Columns can automatically resize to &quot;just fit&quot;
  • 26. ListView and GridView Live Demo
  • 28. TreeView Presents a hierarchical view Data with nodes that can be expanded and collapsed Important events: Expanded Collapsed Selected Unselected
  • 30. GroupBox and Expander
  • 31. GroupBox and Expander Both provide a container for arbitrary content and a place for a header on top Expander can be expanded and collapsed GroupBox always shows its content Both controls derive from HeaderedContentControl We can place whatever content we like directly inside the control
  • 32. GroupBox and Expander Live Demo
  • 33. Menus
  • 34. Menu Menu simply stacks its items horizontally <Menu Height=&quot;23&quot; VerticalAlignment=&quot;Top&quot; > <MenuItem Header=&quot;_File&quot;> <MenuItem Header=&quot;_New...&quot;/> <MenuItem Header=&quot;_Open...&quot;/> <Separator/> <MenuItem Header=&quot;Sen_d To&quot;> <MenuItem Header=&quot;Mail Recipient&quot;/> <MenuItem Header=&quot;My Documents&quot;/> </MenuItem> </MenuItem> <!--(the example continues)-->
  • 35. Menu (2) <MenuItem Header=&quot;_Edit&quot;> … </MenuItem> <MenuItem Header=&quot;_View&quot;> … </MenuItem> </Menu> <!-- The result is -->
  • 36. MenuItem MenuItem is a headered items control The Header is actually the main object MenuItem contains many properties for customizing Icon IsCheckable InputGestureText Can handle events or assign a command to MenuItem ’s Command property
  • 38. ContextMenu Works just like Menu It’s a simple container designed to hold MenuItems and Separators Must attach it to a control via ContextMenu property When a user right-clicks on the control the context menu is displayed <ListBox> <ListBox.ContextMenu> <ContextMenu> … </ContextMenu> </ListBox.ContextMenu> … </ListBox>
  • 40. Toolbars Toolbars provide faster access for frequently used operations WPF supports toolbars through the ToolBarTray and ToolBar controls StatusBar behaves just like Menu It’s typically used along the bottom of a Window
  • 42. Other C ontrols
  • 43. Slider and Scroll Controls Allow a value to be selected from a range They show a track, indicating the range and a draggable &quot;thumb&quot; The ScrollBar control is commonly used in conjunction with some scrolling viewable area Control the size of a scroll bar’s thumb with the ViewportSize property
  • 44. Slider and Scroll Controls (2) Slider control is used to adjust values Slider and ScrollBar have an Orientation property They both derive from a common base class, RangeBase Provides Minimum and Maximum , SmallChange and LargeChange properties
  • 45. ProgressBar H elps user realize that progress is indeed being made ProgressBar has a default Minimum of 0 and a default Maximum of 100 IsIndeterminate property True - ProgressBar shows a generic animation Orientation property Horizontal by default
  • 46. ToolTip Allows a floating label to be displayed above some part of the user interface To associate a ToolTip with its target element set it as the ToolTip property of its target <TextBox Width=&quot;147&quot; Height=&quot;25&quot;> <TextBox.ToolTip> <ToolTip Content=&quot;Type something here&quot; /> </TextBox.ToolTip> <!--The result is--> </TextBox>
  • 48. How To Make Custom User Control? From the Solution Explorer click Add –> User Control After that it is like you are making a Window After you finish the creation of the UserControl build the project Then you have your UserControl in the Toolbox menu
  • 49. Adding Properties to Custom User Control To add a Property in the UserControl you need a DependencyProperty , e.g. public static readonly DependencyProperty SourceProperty; static ImageButton() { SourceProperty = DependencyProperty.Register( &quot;Source&quot;, typeof(ImageSource), typeof(ImageButton))); } public ImageSource Source { get { return (ImageSource)GetValue(SourceProperty); } set { SetValue(SourceProperty, value); } }
  • 50. Adding Properties to Custom User Control (2) To make the &quot; Source &quot; property work we have to use binding in the Xaml code For the binding we need to set the x:Name of the UserControl Now in our Window we can set an image in our custom ImageButton control <Image Source=&quot;{Binding ElementName= ImageButtonUserControl , Path=ImageSource }&quot;/> < my:ImageButton ImageSource =&quot;Panda.png&quot;/>
  • 51. Custom User Controls Live Demo
  • 53. Exercises Write a program that show the simple window with one Tex t Box . Add text to the Tex t Box. If you select some text in the TextBox – display the current selection information. Write a program with a Button and a Label . The label should show the number of clicks on the button. Write a program that visualize which one of the items collection are checked. Write a program that shows a ComboBox with various elements added to its Items. For example – add text, ellipse and picture.
  • 54. Exercises (2) Write a program that shows ListView with columns that contain controls such as checkboxes and text boxes. The name of the columns are ID, Enabled, Value. Write a text editing user control that is like simple WordPad. It should have at least a TextWrap property, Scrollbar , Buttons for Save and Load, ComboBoxes for choosing FontFamily and FontSize .
  • 55. Exercises (3) Implement a specialized editor of text document libraries. A library is a number of text documents, organized as a tree in folders. In a folder there can be documents and other folders (as in Windows). Every document is some text with formatting. The editor must be able to create libraries, to open/save libraries, to read/write libraries from/to XML files. When a library is open the editor can edit the documents inside (changing the text and the formatting) and can create/delete/rename folders and documents. Use a TreeView for the folder tree and RichTextBox for the active document.
  • 56. Exercises (4) The editor should have a main menu, 2 context menus (for the folder tree and for the active document area), 3 tool bars (to open/save a library, to facilitate working with the folder tree and one for the active document), a status bar and appropriate shortcuts for the most frequently used

Editor's Notes

  • #2: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #3: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #4: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #5: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #8: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #10: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #11: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #14: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #15: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #18: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #21: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #22: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #24: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #27: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #28: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #31: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #33: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #34: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #38: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #40: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #42: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #43: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #54: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #55: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • #57: * 02/25/12 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##