V 1.0 Programming III. Converters Resources. V 1.0ÓE-NIK, 2014 Converters Data conversion: –Can be automatic! E.g.: SolidColorBrush  string, int  string.

Slides:



Advertisements
Similar presentations
Symbol Table.
Advertisements

Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
Dinko Jakovljević Microsoft Student Partner | BambooLab
Intermediate code generation. Code Generation Create linear representation of program Result can be machine code, assembly code, code for an abstract.
Introduction to the C# Programming Language for the VB Programmer.
Advanced Object-Oriented Programming Features
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
Classes and objects Practice 2. Basic terms  Classifier is an element of the model, which specifies some general features for a set of objects. Features.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
Understanding Code Compilation and Deployment Lesson 4.
V 1.0 Programming III. XML XAML Data Binding I.. V 1.0ÓE-NIK, 2014 XML (w3schools.com) A hierarchical way of defining data XML declaration + elements.
V 1.0 Programming III. Creation of additional windows Routed events.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
Last lecture data binding, binding object markup extension bind to any prop with INotifyPropertyChanged, target must be dep. prop. bind to obj... so no.
1 Intro XAML Attribute syntax & property syntax Panels Reusable resources Controls Data binding Steen Jensen, spring 2014.
V 1.1 Programming III. GUI APIs WPF Hello World Important UI elements UI elements / content models UI elements / inheritance.
Windows Presentation Foundation. Agenda Introduction Developing Applications WPF and WF interoperability Custom Controls Styles and Templates Data Binding.
Tutorial C#. PLAN I. Introduction II. Example of C# program :Hello World III. How to use C# language GUI elements Primitives Types Expressions and operators.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
V 1.0 Programming III. Comparison of GUI APIs WPF Hello World UI elements Content models Inheritance chains.
Adam Calderon – C# MVP Application Development Practice Lead Interknowlogy.
V 1.1 Programming III. Creating additional windows Event handling: preview/routed events.
V 1.0 Programming III. Automatic notifications (…Changed, INofityPropertyChanged, ObservableCollection ) Data formatters Data conversions Resources.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
Introduction to Building Windows 8.1 & Windows Phone Applications.
Introduction to Exception Handling and Defensive Programming.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL.Net Assignments K. R. C. Wijesinghe Trainer Virtusa Corporation.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Copyright © 2012 Pearson Education, Inc. Chapter 9 Classes and Multiform Projects.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Security Panel Application Introducing the Select Case Multiple-Selection Statement.
Object Oriented Software Development 10. Persistent Storage.
Svetlin Nakov Telerik Corporation
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
Internationalization in ASP.NET 2.0. SQL Server 2005 – Data Columns Use Unicode datatypes in: Table columns, CONVERT() and CAST() operations Use Unicode.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Module 3 Designing and Developing a User Interface.
V 1.0 Programming III. Recap Drawing / Geometry classes.
1 ENGI 2420 Structured Programming (Lab Tutorial 8) Memorial University of Newfoundland.
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.
Introduction to Object-Oriented Programming Lesson 2.
1 Reverse a String iPhone/iPad, iOS Development Tutorial.
04 |Sharing Code Between Windows 8 and Windows Phone 8 in Visual Studio Ben Riga
V 1.0 Programming III. Automatic notifications with data binding (…Changed, INofityPropertyChanged, ObservableCollection, DataTemplate) Data formatters.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
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.
V 1.0 Programming III. Visual/FrameworkElement descendants.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Windows Presentation Foundation Ruwan Wijesinghe.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
OE-NIK HP Advanced Programming Using and creating DLL files.
Data Binding, Binding Properties Doncho Minkov Telerik School Academy Technical Trainer
Jim Fawcett, Brown Bag Seminar Series Fall 2007
Metropolia 2013 C# programming and .NET framework
Ben Riga 02 | Basics of View Models Ben Riga
Jim Fawcett, Brown Bag Seminar Series Fall 2007
Types of Programming Languages
XAML User Interface Creation in C#
Java Review: Reference Types
03 | Building Windows Store Apps with XAML Part 3
Review Session Biggest discrepancy questions
Andy Wang Object Oriented Programming in C++ COP 3330
Automation and IDispatch
SPL – PS1 Introduction to C++.
Presentation transcript:

V 1.0 Programming III. Converters Resources

V 1.0ÓE-NIK, 2014 Converters Data conversion: –Can be automatic! E.g.: SolidColorBrush  string, int  string –Otherwise, we have to use a class that implements the IValueConverter interface (System.Windows.Data) –Two methods: Convert(), ConvertBack() Convert(): source  target (VM  UI) ConvertBack(): target  source (UI  VM) After the ConvertBack(), the getter is executed (along with the Convert()) 2 <ListBox x:Name=“lbColors" BorderBrush= "{Binding ElementName=lbColors, Path=SelectedItem}”.../>

V 1.0ÓE-NIK, 2014 Converters Person class: –Name (string) –Age (int) Binding: pesron.Age  label.Content 3 <Window... xmlns:current="clr-namespace:WpfApplication9”... > Reference the.NET namespace Import the.NET converter class into the XAML Assign the converter to the binding

V 1.0ÓE-NIK, 2014 Converters Converter class –In this form, only one-way conversion is required –Look out for the data types! 4 class AgeValueConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int kor = (int)value; if (kor < 18) return "child"; else if (kor < 30) return "young"; else if (kor < 50) return "middle-aged"; else if (kor < 65) return "older"; else return "old"; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }

V 1.0ÓE-NIK, 2014 Resources A resource is a class/instance that we can reuse in our application multiple times Types: –Logical/class resources: arbitrary instances (created in XAML) –Binary resources: images, icons, lookup tables... The logical resources are stored in the resource dictionary, each of them has a unique name (x:Key) –Resources property (in FrameworkElement descendants) Contained controls will receive the parent controls’ resources 5 <Window Import the class into the resource dictionary of the Grid

V 1.0ÓE-NIK, 2014 Resources Logical/class resources can be used in other places: –Brushes, colors, styles, templates, converters –Arbitrary instances (e.g. arrays) –E.g.: color (brush) in the resource dictionary: Types: –StaticResource: created once when the XAML is loaded, read-only –DynamicResource: loaded in run-time, it can be modified 6... <Label Background="{StaticResource ResourceKey=MyColor}" Content=“Text with nice color...".../>

V 1.0ÓE-NIK, 2014 Resources Binary resources: –The project can include arbitrary files that the application needs –To include a file as a binary resource, it has to be added to the project, then in the properties window we have to change the “Build Action” of the file Resource: the compiler will embed the data into the.NET assembly Content: the files will remain external files, we have to change the “copy to output directory” setting as welll We can reference them in the XAML with their filename 7

V 1.0ÓE-NIK, 2014 Feladat Team = center + left wing + right wing + 2 defender + goalie Name = only characters 8