Basic WPF Controls Doncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer

Slides:



Advertisements
Similar presentations
Information System Design Lab 5&6. User Interface Design.
Advertisements

What is a Dialog box? A Dialog box is a window or “form” that contains other child windows or “controls” that have a specific appearances and pre-defined.
Microsoft Word Basics. Introduction to Microsoft Word Microsoft Word is a word processor designed by Microsoft. A word processor is a computer application.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 3-1 of…
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic Chapter 1 Mr. Wangler.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Doncho Minkov Telerik School Academy academy.telerik.com Technical Trainer
IE 411/511: Visual Programming for Industrial Applications
CSCI 3328 Object Oriented Programming in C# Chapter 2: Introduction to Visual C# Programming 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
WaveMaker Visual AJAX Studio 4.0 Training Basics: Building Your First Application Designer Basics.
Visual Basic.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
C# kursus Rohde & Schwarz1 Moderne GUI Windows Presentation Foundation.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Visual Basic CDA College Limassol Campus Lecture:Pelekanou Olga Semester C Week - 1.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Win32 Controls & ActiveX Integration In this presentation… –Introduction to the new Win32 controls. What they are? How they are enabled? Potential uses.
ControlTemplate and DataTemplate Doncho Minkov Telerik School Academy Technical Trainer
Module 3 Designing and Developing a User Interface.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
1 Visual Basic Part I - A tool for customizing your program Principles of GIS
Module 4 Taking Control of the User Interface. Module Overview Sharing Logical Resources in an Application Creating Consistent User Interfaces by Using.
Controls. Common properties Height – Height of the control Left – Left of the control Width – width of a control Top - From the screen top Font – Foreground.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Compunet Corporation Programming with Visual Basic.NET Working with Menus and Dialog Boxes Week 14 Tariq Aziz and Kevin Jones.
Building User Interfaces Basic Applications
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
PowerBuilder Window Window Controls Window Properties Window Types
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
MS WORD INFORMATION TECHNOLOGY MANAGEMENT SERVICE Training & Research Division.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Dive Into® Visual Basic 2010 Express
Introducing WPF’s controls
Visual Basic.NET Windows Programming
Prashanth Vijayaraghavan
Chapter 1: An Introduction to Visual Basic 2015
CSCI 3328 Object Oriented Programming in C# Chapter 2: Introduction to Visual C# Programming UTPA – Fall 2012 This set of slides is revised from lecture.
3.01 Apply Controls Associated With Visual Studio Form
Chapter 2 Visual Basic Interface
The University of Texas – Pan American
Creating a Windows Forms User Interface
Visual Studio.
Web Development Using ASP .NET
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

Basic WPF Controls Doncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer

1. WPF Controls 2. Text controls 3. Buttons 4. List controls 5. GroupBox and Expander 6. Menus 7. Toolbars 2

8. Other controls  Slider and Scroll controls  ProgressBar  ToolTip  Custom User Controls 3

 WPF controls are typically not directly responsible for their own appearance  The are all about behavior  They defer to templates to provide their visuals 5

 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 6

 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 8

Live Demo

 TextBox is control for editing and displaying text  By setting AcceptsReturn to true, it can edit multiple lines 11 <TextBox Margin="5" VerticalAlignment="Center" Text="Single line textbox" /> Text="Single line textbox" /> <TextBox AcceptsReturn="True" Margin="5" Height="50 VerticalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" VerticalAlignment="Center" Text="Multiline textbox" /> VerticalAlignment="Center" Text="Multiline textbox" />

 RichTextBox supports all of the commands defined by the EditingCommands class  Recognize the RTF format  Paste formatted text from Internet Explorer and Word  Both TextBox and RichTextBox offer built-in spellchecking  SpellCheck.IsEnabled attached property 12

Live Demo

 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 15 Click Click void ButtonClicked(object sender, RoutedEventArgs e) { MessageBox.Show("Button was clicked"); MessageBox.Show("Button was clicked");} ButtonsWindow.xaml ButtonsWindow.xaml.cs

 Holds its state when it is clicked  IsChecked property  IsThreeState property  Gives 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 16

Live Demo

 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 18

 Grouping radio buttons by name 19 <StackPanel> <RadioButton GroupName="Fuel" <RadioButton GroupName="Fuel" Margin="3">Petrol Margin="3">Petrol <RadioButton GroupName="Fuel" <RadioButton GroupName="Fuel" Margin="3">Diesel Margin="3">Diesel <RadioButton GroupName="Induction" <RadioButton GroupName="Induction" Margin="3">Unforced Margin="3">Unforced <RadioButton GroupName="Induction" <RadioButton GroupName="Induction" Margin="3">Mechanical supercharger Margin="3">Mechanical supercharger <RadioButton GroupName="Induction" <RadioButton GroupName="Induction" Margin="3">Turbocharger Margin="3">Turbocharger </StackPanel>

Live Demo

 Enables users to select one item from a list  ComboBox defines two events  DropDownOpened  DropDownClosed  ComboBox can contain complex items 22

Live Demo

 The ListView control derives from ListBox  It uses the Extended SelectionMode by default  View property  Enable customize the view in a richer way  The View property is of type ViewBase, an abstract class 24

 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 "just fit" 25

Live Demo

 Presents a hierarchical view  Data with nodes that can be expanded and collapsed  Important events:  Expanded  Collapsed  Selected  Unselected 28

Live Demo 29

 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 31

Live Demo

 Menu simply stacks its items horizontally 34

35 … … … … </Menu>

 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 36

Live Demo

 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 38 <ListBox> … … </ListBox>

 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 40

Live Demo

 Allow a value to be selected from a range  They show a track, indicating the range and a draggable "thumb"  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 43

 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 44

 Helps 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 45

 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 46 </TextBox>

 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

 To add a Property in the UserControl you need a DependencyProperty, e.g. 49 public static readonly DependencyProperty SourceProperty; static ImageButton() { SourceProperty = DependencyProperty.Register( SourceProperty = DependencyProperty.Register( "Source", typeof(ImageSource), typeof(ImageButton))); "Source", typeof(ImageSource), typeof(ImageButton)));} public ImageSource Source { get { return (ImageSource)GetValue(SourceProperty); } get { return (ImageSource)GetValue(SourceProperty); } set { SetValue(SourceProperty, value); } set { SetValue(SourceProperty, value); }}

 To make the " Source " 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 50 <Image Source="{Binding ElementName= ImageButtonUserControl, Path=ImageSource}"/> ImageButtonUserControl, Path=ImageSource}"/>

Live Demo

Questions?

1. Write a program that show the simple window with one TextBox. Add text to the TextBox. If you select some text in the TextBox – display the current selection information. 2. Write a program with a Button and a Label. The label should show the number of clicks on the button. 3. Write a program that visualize which one of the items collection are checked. 4. Write a program that shows a ComboBox with various elements added to its Items. For example – add text, ellipse and picture. 53

5. 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. 6. 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. 54

7. 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. 55

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 56