Introduction to C#, Visual Studio and Windows Presentation Foundation



Similar documents
Understanding In and Out of XAML in WPF

Windows Presentation Foundation (WPF)

ComponentOne. Windows for WPF

Implementing multi-user multi-touch scenarios using WPF in Windows* 8 Desktop Apps

Windows Presentation Foundation Tutorial 1

Hands-On Lab. Building a Data-Driven Master/Detail Business Form using Visual Studio Lab version: Last updated: 12/10/2010.

This tutorial has been designed for all those readers who want to learn WPF and to apply it instantaneously in different type of applications.

Windows Presentation Foundation Using C#

Example. Represent this as XML

Name of chapter & details

70-484: Essentials of developing Windows Store apps using C#

Introduction to the BackgroundWorker Component in WPF

App Development for Modern UI MODULE 4: APP DEVELOPMENT ESSENTIALS

Visual Studio 2008: Windows Presentation Foundation

Creating a Web page L E S S O N 8. Suggested teaching time. Lesson objectives minutes. To be able to create a Web page, you will:

Using WPF for Computer Graphics

An Introduction to the Windows Presentation Foundation with the Model-View-ViewModel

Microsoft Virtual Labs. Building Windows Presentation Foundation Applications - C# - Part 1

San Joaquin County Office of Education Career & Technical Education Web Design ~ Course Outline CBEDS#: 4601

Dreamweaver. Introduction to Editing Web Pages

Windows Presentation Foundation (WPF) User Interfaces

PORTAL ADMINISTRATION

WP Popup Magic User Guide

Windows Presentation Foundation

1. WPF Tutorial Page 1 of 431 wpf-tutorial.com

STEP BY STEP to Build the Application 1. Start a. Open a MvvmLight (WPF4) application and name it MvvmControlChange.

Hands-On Lab. Client Workflow. Lab version: Last updated: 2/23/2011

Generating lesson plans with. Adobe Acrobat

TUTORIAL 4 Building a Navigation Bar with Fireworks

How to create pop-up menus

Website Builder Overview

Visual Basic. murach's TRAINING & REFERENCE

Hypercosm. Studio.

Composite.Community.Newsletter - User Guide

Extending XSLT with Java and C#

Microsoft Silverlight 5: Building Rich Enterprise Dashboards Todd Snyder, Joel Eden, Ph.D. Jeff Smith, Matthew Duffield

Building and Using Web Services With JDeveloper 11g

آموزش DataGrid در WPF به همراه صفحه بندي و جستجوي انتخابی. کلیک کن

MAX 2006 Beyond Boundaries

Fireworks CS4 Tutorial Part 1: Intro

Agenda2. User Manual. Agenda2 User Manual Copyright Bobsoft 1 of 34

Relationships in WPF Applications

Acrobat X Pro Accessible Forms and Interactive Documents

What s New / Data Visualization. JASON BERES : VP, Product Management jasonb@infragistics.com

wpf5concat Start Microsoft Visual Studio. File New Project WPF Application, Name= wpf5concat OK.

Adaptive Enterprise Solutions

Improved Navigation Magento Extension User Guide

Contents. Launching FrontPage Working with the FrontPage Interface... 3 View Options... 4 The Folders List... 5 The Page View Frame...

Top 50 WPF Interview Questions

To Begin Customize Office

Oracle Forms Developer 10g: Build Internet Applications

InfoPath 2010 Essentials. Corporate Training Materials

Google Sites: Site Creation and Home Page Design

New Features in Microsoft Office 2007

SPHOL326: Designing a SharePoint 2013 Site. Hands-On Lab. Lab Manual

Microsoft Surface Lab #2: Surface Controls

Introduction to Tizen SDK Alpha. Taiho Choi Samsung Electronics

Bitrix Site Manager 4.1. User Guide

Source Code Translation

Customize and Print AirLiner Slate Underlays Using the SMART Board Software Contro...

DEVELOPMENT OF AN ANALYSIS AND REPORTING TOOL FOR ORACLE FORMS SOURCE CODES

For Introduction to Java Programming, 5E By Y. Daniel Liang

ultimo theme Update Guide Copyright Infortis All rights reserved

SnagIt Add-Ins User Guide

Exam Ref : Essentials of Developing. Windows Store Apps. Using C# Indrajit Chakrabarty

ultimo theme Update Guide Copyright Infortis All rights reserved

Crystal Reports. For Visual Studio.NET. Designing and Viewing a Report in a Windows Application

Windows Store App Development

Smart Connection 9 Element Labels

JavaFX Session Agenda

Excel basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Microsoft Expression Web

Dreamweaver Tutorial - Dreamweaver Interface

SAHARA DIGITAL8 RESPONSIVE MAGENTO THEME

Creating Online Surveys with Qualtrics Survey Tool

70-481: Essentials of developing Windows Store apps using HTML5 and JavaScript

MICROSOFT ACCESS 2003 TUTORIAL

Data Binding with WPF: Binding to XML

Skills for Employment Investment Project (SEIP)

Umbraco v4 Editors Manual

Using HTML5 Pack for ADOBE ILLUSTRATOR CS5

Oracle Application Development Framework Overview

Building a Personal Website (Adapted from the Building a Town Website Student Guide 2003 Macromedia, Inc.)

Table of contents. 1. About the platform MetaTrader 4 platform Installation Logging in 5 - Common log in problems 5

STATEMENT OF PURPOSE

Word basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

WP Popup Magic User Guide

Developer Tutorial Version 1. 0 February 2015

Fireworks 3 Animation and Rollovers

Changing Your Cameleon Server IP

Introduction to Visual Basic

Creating tables of contents and figures in Word 2013

Macromedia Dreamweaver 8 Developer Certification Examination Specification

ARCONICS CONTENT MANAGEMENT SYSTEM FOR UL

Creating Acrobat Forms Acrobat 9 Professional

WPF Shapes. WPF Shapes, Canvas, Dialogs 1

Terms and Definitions for CMS Administrators, Architects, and Developers

SelectSurvey.NET Developers Manual

Qualtrics Survey Software. Create an Account

Responsive Web Design for Teachers. Exercise: Building a Responsive Page with the Fluid Grid Layout Feature

Transcription:

Introduction to C#, Visual Studio and Windows Presentation Foundation Lecture #3: C#, Visual Studio, and WPF Joseph J. LaViola Jr. Fall 2008 Fall 2008 CAP 6938 Topics in Pen-Based User Interfaces Joseph J. LaViola Jr. C# Combination of C++ and Java no pointer manipulation built in data structures Lists, Hash tables some higher level constructs foreach C# not difficult.net high learning curve Intellisense makes things much easier Quick C# Reference 1

Visual Studio 2008 Good IDE debugging intellisense Handles WPF well Visual UI designer Integrates with XAML Windows Presentation Foundation (WPF) Latest UI development platform from MSFT Integration of INK!!!! 2D graphics 3D graphics video/audio/animation Declarative/Procedural programming model XAML C#/Visual Basic/etc Uses retained mode implies scenegraph www.markmywords.org blogs.msdn.com/mgrayson/ 2

WPF Features and Machinery Control library buttons, sliders, menus, toolbars tool tips, popups, scroll bars, etc user defined as well Layout panels canvas, stack, wrap, doc panels grid most flexible Actions events commands triggers Styles, skins, themes, templates Logical and Visual Trees in WPF UIs are constructed from a tree of objects (logical tree) Visual tree expands logical tree nodes broken down into visual components not all logical tree nodes appear in visual tree System.Windows.Media.Visual System.Windows.Media.Visual3D 3

Extensible Application Markup Language (XAML) Set of semantics on top of XML Tags always defined in context namespace Easy to read like and write a.k.a. HTML declarative want to integrate graphic designers Independent of WPF Ideal for rapid UI prototyping set up UI then write procedural code WPF Example Button <Window xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation 'Title='Hello World'> <Button>Howdy!</Button> Examples adapted from Essential Windows Presentation Foundation by Chris Anderson, Addison Wesley, 2007. 4

WPF Example Stack Panel <Window xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Title='Hello World' > <StackPanel> <Button>Howdy!</Button> <Button>A second button</button> </StackPanel> WPF Example More Controls <Window xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Title='Hello World' > <StackPanel> <Button>Howdy!</Button> <Button>A second button</button> <TextBox>An editable text box</textbox> <CheckBox>A check box</checkbox> <Slider Width='75' Minimum='0' Maximum='100' Value='50' /> </StackPanel> 5

WPF Example Wrap Layout <Window xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Title='Hello World' > <WrapPanel> <Button>Howdy!</Button> <Button>A second button</button> <TextBox>An editable text box</textbox> <CheckBox>A check box</checkbox> <Slider Width='75' Minimum='0' Maximum='100' Value='50' /> </WrapPanel> WPF Example Events <Window x:class= CAP5937Test.MyWindow' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Title='Hello World' > <WrapPanel> <Button Click='HowdyClicked'>Howdy!</Button> <Button>A second button</button> <TextBox x:name='_text1'>an editable text box</textbox> <CheckBox>A check box </CheckBox> <Slider Width='75' Minimum='0' Maximum='100' Value='50' /> </WrapPanel> using System; using System.Windows.Controls; using System.Windows; namespace CAP5937Test { public partial class MyWindow : Window { public MyWindow() { InitializeComponent(); } void HowdyClicked(object sender, RoutedEventArgs e) { _text1.text = "Hello from C#"; } } } Click 6

WPF Example Resource Binding <Window.Resources> <SolidColorBrush x:key='bg' Color='Red' /> </Window.Resources> <WrapPanel> <Button Background='{StaticResource bg}' Click="HowdyClicked"> Howdy!</Button> <Button Background='{StaticResource bg}'>a second button</button> WPF Example Property Binding <Button Background='{StaticResource bg}'>a second button</button> <TextBox x:name='_text1'>an editable text box</textbox> <CheckBox Content='{Binding ElementName=_text1,Path=Text}' /> 7

WPF Actions 3 principles element composition loose coupling declarative actions Uses events, commands, and triggers Utilize routed events traverse visual tree Semantic events vs. physical events Click vs. MouseDown WPF Events Declare events in XAML/implement in code Routed events Direct fire on single source Tunneling travel from root to target element Bubbling opposite of tunneling Tunneling version prefixed with Preview Handled property can break traversal 8

Event Ordering Example <Window... PreviewMouseRightButtonDown='WindowPreviewRightButtonDown' MouseRightButtonDown='WindowRightButtonDown' > <GroupBox PreviewMouseRightButtonDown='GroupBoxPreviewRightButtonDown' MouseRightButtonDown='GroupBoxRightButtonDown' > <StackPanel> <Button>One</Button> <Button PreviewMouseRightButtonDown='ButtonTwoPreviewRightButtonDown' MouseRightButtonDown='ButtonTwoRightButtonDown' > Two </Button> </StackPanel> </GroupBox> Ordering 1. Window PreviewMouseRightButtonDown 2. GroupBox PreviewMouseRightButtonDown 3. Button PreviewMouseRightButtonDown 4. Button MouseRightButtonDown 5. GroupBox MouseRightButtonDown 6. Window MouseRightButtonDown Commands Provide single name to signify an action define command define command implementation create trigger for command Uses ICommand interface public interface ICommand { event EventHandler CanExecuteChanged; bool CanExecute(object parameter); void Execute(object parameter); } 9

Command Example public class Exit : ICommand { public bool CanExecute(object parameter) { return true; } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { Application.Current.Shutdown(); } } <MenuItem Header='_File'> <MenuItem Header='E_xit'> public partial class Window1 : Window { public static readonly ICommand ExitCommand = new Exit(); } <MenuItem Header='_File'> <MenuItem Header='E_xit Command='{x:Static l:window1.exitcommand}' /> </MenuItem> </MenuItem> <MenuItem.Command> <l:exit /> </MenuItem.Command> </MenuItem> </MenuItem>... <Hyperlink> <Hyperlink.Command> <l:exit /> </Hyperlink.Command>... </Hyperlink> Triggers Designed for markup Signaled by state of a display property (Trigger) state of a data property (DataTrigger) used only within a data template an event (EventTrigger) Cause set of actions when signaled MultiTrigger and MultiDataTrigger 10

Event Trigger Example <Window.Triggers> <EventTrigger RoutedEvent='FrameworkElement.Loaded'> <EventTrigger.Actions> <BeginStoryboard> <BeginStoryboard.Storyboard> <Storyboard> <DoubleAnimation From='-25' To='25' Storyboard.TargetName='rotation' Storyboard.TargetProperty='Angle' AutoReverse='True' Duration='0:0:2.5' RepeatBehavior='Forever'/> </Storyboard> </BeginStoryboard.Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Window.Triggers> Readings Windows Presentation Foundation by Nathan Chapters 1-7 11