Windows Presentation Foundation. Agenda Introduction Developing Applications WPF and WF interoperability Custom Controls Styles and Templates Data Binding.

Slides:



Advertisements
Similar presentations
Module 1: Creating an Application by Using Windows Presentation Foundation Overview of WPF Creating a Simple WPF Application Handling Events and Commands.
Advertisements

Designing, Deploying and Managing Workflow in SharePoint Sites Steve Heaney Product Development Manager OBS
Expression Blend 4 – deep dive
The Microsoft Technical Roadshow 2006 Windows Presentation Foundation (WPF) Marcus Perryman
CST238 Week 8 Questions / Concerns? Announcements – Check-off Take Home lab#7 GUI Bloopers presentations (#5) New topics – Printing Richtext box Graphics.
Data Binding in GUI Application Development Patrick O’Brien.
Dinko Jakovljević Microsoft Student Partner | BambooLab
An Introduction To Silverlight Gergely Orosz
DEV392: Extending SharePoint Products And Technologies Through Web Parts And ASP.NET Clint Covington, Program Manager Data And Developer Services - Office.
Windows Presetation Foundation (WPF) 1. Introduction.
Originally founded in 1985 as Rock Financial by Dan Gilbert Grew to one of the largest independent mortgage banks in the country 1998 IPO 1999 Launched.
Advanced Object-Oriented Programming Features
Create Windows ® Applications with.NET Allan Knudsen.NET Developer Evangelist Microsoft.
Aptech Borivali(West) Hefin Dsouza. Agenda  What is.NET and What is Visual Studio? .NET Framework 3.5 Overview.  Visual Studio 2008 Enhancements. 
Create with SharePoint 2010 Jen Dodd Sr. Solutions Consultant
WinFX – A Lap Around the Windows Presentation Foundation Bart J.F. De Smet MVP Visual C#
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
WPF For PowerBuilder Developers
2 A First Look at Windows Presentation Foundation Everywhere ("WPF/E") Joe Stegman Lead Program Manager Microsoft Corporation.
READING, WRITING, BINDING, VALIDATING AND VISUALISING YOUR DATA Business value with Silverlight.
Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University.
1 COS240 O-O Languages AUBG, COS dept Lecture 33 Building Apps Technologies C# (WPF part 1)
Eric Westfall – Indiana University Jeremy Hanson – Iowa State University Building Applications with the KNS.
Module 11 Control Customization. Module Overview Overview of Control Authoring Creating Controls Managing Control Appearance by Using Visual States Integrating.
A Jumpstart to WPF by Kevin Grossnicklaus ArchitectNow.
1 Intro XAML Attribute syntax & property syntax Panels Reusable resources Controls Data binding Steen Jensen, spring 2014.
An Introduction to Silverlight Matt Harrington Developer Evangelist, Microsoft October 20, 2011.
Virtual techdays INDIA │ Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri.
CS360/CS580H GUI & Windows Programming Introduction.
Windows Presentation Foundation Adam Calderon Principal Engineer Interknowlogy LLC
Silverlight Technology. Table of Contents 1.What is Silverlight Technology? 2.Silverlight Overview. 2.1 How it works 2.2 Silverlight development tools.
LAYOUT CONTROLS. XAML Overview XAML : eXtensible Application Markup Language pronounced (ZAMEL) is a markup language used to design user interfaces XML-based.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
The Microsoft Technical Roadshow 2007 Rich Client Development in XAML Mark Johnston Developer & Platform Group Microsoft Ltd
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Windows Presentation Foundation Ruwan Wijesinghe.
Create Windows ® Applications with.NET Carlotta Eaton ( Associate Professor of IST New River Community College Slides by Microsoft.
Svetlin Nakov Telerik Corporation
A Lap Around Windows Presentation Foundation. Why hasn’t UX taken off in software? It’s Difficult! Animation 2D 3D Documents Styled Controls Video Windows.
WPF – Windows Presentation Foundation what is it, what can you do with it and how do you get started.
ControlTemplate and DataTemplate Doncho Minkov Telerik School Academy Technical Trainer
© Copyright SELA software & Education Labs Ltd Baruch Hirsch St.Bnei Brak Israel
1 Catching up on Rich Clients (round 1) Mike Ormond, Mike Taulty Developer & Platform Group Microsoft Ltd
Module 4 Taking Control of the User Interface. Module Overview Sharing Logical Resources in an Application Creating Consistent User Interfaces by Using.
1 Välkommen till Sommarkollo Windows Presentation Foundation Per Östman ISV Developer Evangelist
.NET Framework Presentation. About Me Patrik Löwendahl –C# MVP –Certified Vista Touchdown Trainer Cornerstone
Slide 1. Agenda  Introduction to Windows Workflow What is it? What are activities? Hosting  Out of the box Activities  Custom Activities and Dependency.
Friday, March 8 Creating real Custom Controls Kelvin van Geene 12:15.
Extending SharePoint through Web Parts and ASP.NET 최승현 대리 한국마이크로소프트.
V 1.0 Programming III. XAML Data Binding I.. V 1.0ÓE-NIK, 2014 XAML namespaces Namespaces define the allowed tags and attributes The one without the prefix.
1 15. Building Applications with Windows Forms Why Use Windows Forms? Structure of Windows Forms Using Windows Forms Using Controls Code Samples.
The 2007 Microsoft Office System Servers Enterprise Content Management, Workflow and Forms Martin Parry Developer and Platform Group, Microsoft Ltd
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Windows Presentation Foundation Ruwan Wijesinghe.
Soyatec Contents Needs Architecture XAML fundamentals Data Binding Advanced features Style Q&A.
Part of the Microsoft.NET Framework 3.0 Tomer Shamam.NET Technologies Expert Sela Group
Data Binding, Binding Properties Doncho Minkov Telerik School Academy Technical Trainer
Introduction to Silverlight
DotNetSpider Editor Hefin Dsouza
WPF vs Silverlight.
CHAPTER 8 Multimedia Authoring Tools
Introduction to Silverlight
XAML User Interface Creation in C#
Introduction to Silverlight
WPF AKEEL AHMED.
.NET and .NET Core 7. XAML Pan Wuming 2017.
Windows Presentation Foundation
MIX 09 12/8/2018 4:33 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Office 365 Development.
Windows Forms in Visual Studio 2005: An in-depth look at key features
Wordpress.
Presentation transcript:

Windows Presentation Foundation

Agenda Introduction Developing Applications WPF and WF interoperability Custom Controls Styles and Templates Data Binding Graphics Not covered sections Resume

Introduction

Progress WinAPI MFC Windows Forms WPF

WPF Components

Main features New GUI core Declarative programming using XAML Layout system Styles Control Templates Data Templates Flexible Data Binding Graphics and Multimedia support Improved security model Unified document format (XML Paper Specification) Compatibility with Windows Forms

Developing Applications

Developer Environment Visual Studio 2005.NET 3.0 Visual Studio Extensions Windows SDK

Application types XAML browser applications Stand-alone applications –Windows Applications –Hosted in WPF Navigation Window

XAML browser application WPF Everywhere for XAML + browser plug-in Installed using ClickOnce Run in browser Internet Zone security

Stand-alone application User permissions Like a standard Windows Application

Creating stand-alone application Create WPF project –Windows Application (WPF) –Custom Control Library (WPF) Create class –User Control (WPF) –Custom Control (WPF) –Window (WPF) Create styles and templates –Resource dictionary –Local resource

Kinds of WPF Project objects User control –CS code-behind file –XAML declaration Custom control –CS implementation –Style in XAML resource dictionary XAML Resource –Style or Data Template or Control Template in XAML resource dictionary

WPF Application Project structure Application class (User control) –Based on System.Windows.Application –Build action – ApplicationDefinition –StartupUri property in XAML – Window class Window class (User control) –Based on System.Windows.Window User Control class (User control) –Based on System.Windows.Controls.UserControl Custom Control class (Custom control) –Based on System.Windows.Controls.Control –Overrides metadata in static constructor Resource Dictionary (XAML Resource) –Top file tag ResourceDictionary –Main file “themes\generic.xaml”

WPF Application Project screen shot

WPF and WF interoperability

WPF and WF interoperability Agenda Hosting a Windows Form Control in WPF Hosting a WPF Control in Windows Forms Troubleshooting Hybrid Applications

Hosting a WF Control in WPF 1.Create Windows Application (WPF) project 2.Add reference to the WindowsFormsIntegration assembly 3.Add reference to the System.Windows.Forms assembly 4.Create System.Windows.Forms.Integration. WindowsFormsHost host object 5.Set WF control to Child property of host object 6.Add host object onto WPF panel (for example, Window)

Hosting a WF Control in WPF - sample // Creating Windows Form control MaskedTextBox mtbDate = new MaskedTextBox("00/00/0000"); // Creating Integration host WindowsFormsHost host = new WindowsFormsHost(); host.Child = mtbDate; // Appending host to Window this.AddChild(host);

Hosting a WPF Control in WF 1.Create Windows Application (WinForms) project 2.Add references to WindowsFormsIntegration, PresentationCore, PresentationFramework and WindowsBase assemblies 3.Add into project file the following line : Just after 5.Create System.Windows.Forms.Integration.ElementHost host object 6.Add WPF control to host object 7.Add host object on WF Form

Hosting a WPF Control in WF // Create WPF Control TextBlock textBlock = new TextBlock(); textBlock.Text = "WPF TextBlock control"; // Create host ElementHost host = new ElementHost(); host.Child = textBlock; host.Dock = DockStyle.Fill; // Add host to Form this.Controls.Add(host);

Troubleshooting Hybrid Applications Overlapping Controls Child Property Scaling Adapter Nesting Focus Property Mapping Layout-related Properties on Hosted Content Navigation Applications Opacity and Layering Dispose Enabling Visual Styles Licensed Controls

Custom Controls

Models for Control Authoring Restyle existed controls Derive from UserControl Derive from Control Derive from FrameworkElement

Restyle existed controls Simplest way No additional properties Custom control logic only in XAML

Restyle existed controls – example

Restyle existed controls – screen shot

Derive from UserControl Built like Application Composite of existed controls No complex customization

Deriving from UserControl - example <TextBlock Text="{Binding ElementName=parent,Path=LabelText}" Margin="5"/> <TextBox Text="{Binding ElementName=parent,Path=ValueText}" Margin="5"/>

Deriving from UserControl – example <Window x:Class="UserControls.Window" xmlns:l="clr-namespace:UserControls"> <l:UserControl LabelText="Label Text“ ValueText="Value Text"/>

Deriving from UserControl – screen shot

Deriving from Control Flexible way Like most WPF controls Support Control Templates Support Themes

Deriving from Control - example

Deriving from FrameworkElement Own Render way Appearance is defined by own render logic

Styles and Templates

Styling and Templating Resources Style structure Data Templates Control Templates Triggers

Styling and Templating - Resources Store local Styles, Data Templates and Control Templates Apply to FrameworkElement and FrameworkContentElement Share resources via Resource Dictionaries Static and Dynamic resources

Resources example <ResourceDictionary xmlns=" xmlns:x=" xmlns:local="clr-namespace:ControlLibrary">

Styling and Templating – Style structure Naming and Referencing Deriving Styles Setters Data Template Control Template Triggers

Styling and Templating – Data Templates Name and Data Type Visual data content Content Control and Content Presenter Triggers

Styling and Templating – Control Templates Name and Target Type Visual data content Template Attributes Triggers

Styling and Templating – Triggers Trigger and Multi Trigger Data Trigger and Multi Data Trigger Event Trigger and Multi Event Trigger

Data Binding

Binding a dependency property to a CLR property Path == DaraSource Binding only to dependency properties

Data Context 1.The binding looks for a non-null DataContext on the TextBox itself 2.The binding looks for a non-null DataContext on the Grid 3.The binding looks for a non-null DataContext on the Window

Master-Detail Binding public class Families : ObservableCollection { } public class Family { string familyName; public string FamilyName { get { return familyName; } set { familyName = value; } } People members; public People Members { get { return members; } set { members = value; } } public class People : ObservableCollection { } public class Person { string name; public string Name { get { return name; } set { name = value; } } int age; public int Age { get { return age; } set { age = value; } }

Master-Detail Binding <?Mapping XmlNamespace="local" ClrNamespace="MasterDetailBinding" ?>...

Master-Detail Binding Families: <ListBox Grid.Row="1" Grid.Column="0" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}">

Graphics

Not covered sections

Sections Security model Web Browser Applications Using multimedia and graphics Easy to restyle application

Resume

Advantages WPF has very flexible model XAML is a great advance in declarative programming Easy to use multimedia and graphics Easy to restyle application

Disadvantages WPF functionality is not so high as WF one WPF and WF interoperability is buggy VS support of XAML is buggy and not full Most available WPF documentation is out of date