Академический Документы
Профессиональный Документы
Культура Документы
Magenta
Purple
Teal
Lime
Brown
Pink
Orange
Blue
Red
Green
Introduction
to Windows
Store Apps
XAML
Language
Projection
Dynamic
Layout
10
Windows 8 Architecture
11
Introduction
to Windows
Store Apps
XAML
Language
Projection
Dynamic
Layout
HTML +
CSS
+
+
C# / VB /
C++
JavaScript
UI
DirectX
+
Logi
c
C++
13
Applicatio
n Code
C#
Applicatio
n Code
VB
Applicatio
n Code
JavaScript
Applicatio
n Code
Crossplatform
framework
C#
Projection
VB
Projection
JavaScript
Projection
Native API
Native API
Native API
Windows
Runtime
Target
platform
#1
Target
platform
#2
Target
devices
Language Projection
14
XAML+C#
HTML5+JavaScript
Language Projection
15
XAML+C#
HTML5+JavaScript
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<Button x:Name="button1" Content="Click Me!"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
C# code behind
Language Projection
16
XAML+C#
<body>
<div id="mainContent">
<button id="button1">
Click Me!</button>
</div>
</body>
HTML5+JavaScript
#mainContent {
width: 100%; height: 100%; display: -ms-grid;
-ms-grid-rows: 1fr; -ms-grid-columns: 1fr; }
#button1 {
-ms-grid-row-align: center;
-ms-grid-column-align: center; }
17
Results
Language Projection
18
Results
Language Projection
19
Introduction
to Windows
Store Apps
XAML
Language
Projection
Dynamic
Layout
XAML Overview
XAML: eXtensible Application Markup Language
XML-based declarative language for UI
Each XML element maps to an object instance
Each attribute maps to a property of object
Event handlers can be declared
Still the handlers should be implemented in the codebehind
21
Mainly for
programmers
XAML
23
XAML
24
Shapes in XAML
Unlike many other declarative UI languages,
non-widget shapes are supported in XAML
XAML
25
Resource Binding
Any property values can be stored as
resources and then be reused
System resources (system-wide predefined
values)
Local resources (stored in local XAML)
XAML
26
Click
The black
little box on
the right
indicates
that this
value is local
XAML
27
Resulting XAML
<x:String x:Key="MyButtonText">Click Me!</x:String>
XAML
28
Styles
Many UI elements of a same style can be used
e.g., The following buttons use AppBarButtonStyle
29
A style example
<Page.Resources>
<Style TargetType="Button">
<Setter Property="BorderThickness" Value="5" />
<Setter Property="Foreground" Value="Blue" />
<Setter Property="BorderBrush" >
<Setter.Value>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="Yellow" Offset="0.0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1.0" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
30
Data Binding
Data binding can be used between two properties,
as long as the following conditions are met:
1) Data source implements INotifyPropertyChanged
interface
2) The two properties have the same data type,
or there is a data converter
31
Button is
enabled only
if the toggle
switch is on
XAML
32
Displays
slider.Maximum
(OneWay)
Displays
slider.Minimum
(OneWay)
Displays
slider.Value
(TwoWay)
XAML
33
XAML
Visibility (Enum)
Visible
Collapsed
IsOn (Boolean)
True
False
Target Property
Source Property
34
XAML
35
Introduction
to Windows
Store Apps
XAML
Language
Projection
Dynamic
Layout
Scaling UI Elements
There is a special UI element called
Viewbox, whose sole purpose is to resize
content
Stretch=None
No stretch at all
Dynamic Layout
Stretch=Fill
Stretch=Uniform
Dynamic Layout
38
39
An Example Grid
Some Tool Controls
Auto
2*
Dynamic Layout
40
41
Project Templates
Visual Studio provides 3 project templates
Blank App, Grid App, Split App
LayoutAwarePage
Pre-defined visual states (snapped, portrait, landscape, )
SuspensionManager
Storing/restoring UI states upon switching between apps
Problems
Often too heavy for simple apps
Premature commitment very difficult to change later
Dynamic Layout
42
Dynamic Layout
43
Dynamic Layout
44
CONCLUSION
45
Asynchronous programming
Windows charms / App bar
Live tiles
46
Conclusion
Windows App Store is a newly emerging socio-technical
ecosystem
Most of these techniques are not dramatically new, but
well put together to create a developer-friendly
environment
Probably too soon to judge whether this platform is
successful or not
Students can register for a Windows Store developer
account for free, via Dreamspark program
47
Q&A
Thank you!
References
MSDN: Developing Windows Store apps
(http://
msdn.microsoft.com/en-us/library/windows/apps/xaml/br229566.aspx)
MSDN: White papers for Windows Store apps
(http://msdn.microsoft.com/en-US/library/windows/apps/hh465413)
Jeremy Likness, Building Windows 8 Apps with C# and XAML, AddisonWesley Professional
48