Академический Документы
Профессиональный Документы
Культура Документы
-
2013
681.3.06
32.973.26-018.2
88
, . .
88 Windows 8 C# / . . ,
. . , . . . .: -, 2013. 416 .: .
( )
ISBN 978-5-9775-0846-9
Windows Store- Windows 8
C# Visual Studio 2012. -
.
. c
, , , , -
. , -
-
Windows Store.
681.3.06
32.973.26-018.2
.
.
31.10.12.
1
70 100 /16. . . . . 33,54.
3000 .
"-", 191036, -, ., 20.
""
199034, -, 9 , 12/28
Windows,
.......................................................................................................... 9
.......................................................................................................................... 11
....................................................................................................... 11
.................................................................................................................. 12
................................................................................................................................ 14
1. Windows 8 .................................................................................. 15
Windows Store-........................................................................................................... 16
............................................................................................................... 21
Windows Store- ............................................................................................. 23
............................................................................................................................................... 25
2. .......................................................................................... 26
............................................................................................................................................... 30
4. .................................................... 53
.................................................................................. 53
............................................................................................................. 56
............................................................................... 60
.................................................................................... 61
........................................................................... 62
................................................................................................................... 64
.................................................................................................67
............................................................................................................................................... 68
4
5. .......................................................................................... 69
..................................................................................................... 70
............................................................................................................... 72
............................................................................................................................................... 75
6. ...................................................................................... 77
C ..................................................................................................... 79
IsSticky ............................................................................................................................ 83
................................................................................... 83
............................................................................................................................................... 86
9.
.................................................................................. 125
............................................................................................ 126
Visual State Manager ..................................................................................................................... 130
................................ 133
............................................................................................................................................. 135
10. .
................................................................................................. 136
............................................................................................... 136
.................................................................................... 139
/ .................................................................................... 139
........................................................................................................................... 142
........................................................................................................... 146
............................................................................................................................................. 150
................................................................................................ 166
.......................................................................................................................... 169
........................................................................................... 170
......................................................................................... 171
............................................................................................................................ 172
............................................................................................................... 173
............................................................... 175
............................................................................................................... 177
............................................................................................................................................. 179
......................................................................................... 314
............................................................................................................316
............................................................................................................................................. 318
23. ,
Windows 8 .............................................................. 320
............................................................................................. 321
1. ...........................................................................................321
2. ? .......................................................................... 324
3. ....................................................................................... 325
4. ................................................................................................329
5. .................................................................................... 344
............................................................................................................................................. 353
.......................................................................................................... 371
1. XAML .................................................................... 373
........................................................................................................... 376
................................................................................................................. 378
XAML- ........................................................................................ 381
................................................................................................ 383
............................................................................................................. 384
..................................................................................................................... 389
DataContext............................................................................................................ 392
................................................................................................. 396
............................................................................................................................................. 398
2. C# 5 ...................................... 399
async await C# 5......................................................................................... 403
............................................................................................................................................. 407
.............................................................................................. 409
8
Windows,
Windows
1985 .
1,3 !
-
.
,
, .
Windows -
. Windows 8 Microsoft,
, "" -
.
Windows 8 Microsoft
Office, Windows Phone, Visual Studio, Outlook.com ( Hotmail), Microsoft
Account ( Live ID), , . . , Microsoft -
, Windows
.
, . -
Windows ,
, .
Windows 8
.
Windows Store. Windows -
. , -
, , ( ,
) , -
. Windows Store , -
,
Windows, , .
10 Windows,
, , -
, -
C# XAML,
Microsoft, C++ DirectX, ,
HTML 5 JavaScript, Web- .
Windows Windows 3.1. ,
, ,
, .
, , -
, . . .
, , ,
Windows 8.
.
. , , , -
, !
Microsoft
mik@microsoft.com
http://twitter.com/mixen
Windows Store- Windows 8. -
API -
.
C#, -
.
C# , --
, Java,
. -
API (Application Programming Interface, -
) Windows 8, -
C# . C# -
.
:
Microsoft .NET, WPF,
Silverlight, ASP.NET . .,
Windows 8 .
Windows, -
Win32 API, MFC, Qt . .,
Windows 8.
, ,
Windows Phone, Windows Mobile, Android iOS, -
Windows 8.
, Windows 8, -
, -
. , -
, .
12
24- .
.
1 Windows 8.
Windows Store-.
2 ,
Windows Store-: Microsoft Visual Studio, Blend . .
3 Windows 8
, . -
Windows Store- , .
4 Windows Store-
C#. ,
, .
5
: .
6 (Application Bar) -
Windows Store-. -
.
7 RSS- Grid App.
8 GridView ListView,
Windows Store-. -
, .
9 (
320 ) VSM (Visual State
Manager)
.
10
Windows 8, ,
.
11 , ,
Push-, .
12 (Tiles) -
-
.
13
Windows 8 Windows Store-. -
.
14 (Share),
Windows Store-.
13
"-". , -
, .
15 "-" ""
(Settings), .
16 " " .
, . Windows 8
. , -
. -
, . -
, -
. SQLite.
17 .
, Windows Store-
.
. -
, .
, .
18 c Web- -
/ , ,
. , .
19
Microsoft.
20 : ,
, , .
, ,
,
.
21 Windows Store-.
,
.
22 Windows 8. -
Windows 8, Microsoft (-
, Windows Phone, Xbox 360 Visual Studio 2012), -
, -
. ,
.
23
Windows 8.
, , ,
, Windows 8 Windows
Phone, -
(UX UI).
14
( ) -
Windows 8 ,
Web-. "-
" , -
, -
.
, , -
,
, -
( ) -
. Windows Store-
, .
24 Windows Store. -
, .
, .
Windows App Certification Kit , -
, ,
. -
.
1 XAML -
XAML-.
2 . -
, , async await
C# 5.
ftp://ftp.bhv.ru/9785977508469.zip www.bhv.ru.
, :
, , , ,
, , .
, -
, .
"--
" ,
.
Taa1
Windows 8
, Apple iPad,
Windows
, :
1. ,
(Windows 8 , ,
ARM-) , , ,
.
2. (-).
3. .
Windows,
Microsoft
, , .
Windows 95
.
Windows 8 .
Windows Windows Store ,
( ) -
, , .
, Windows 7, Windows 8.
Windows Store , -
Windows Runtime (WinRT). -
Windows Store-. Windows 8 -
. ,
(. 1.1).
Windows Runtime Windows API " -
" Win32 API. Windows
:
16 1
1. Windows-.
2. Windows Store-.
Windows Store- C# Windows Runtime
. -
, API -
.
. 1.1. Windows 8
Windows Store-
, Windows Store-
( , "", "" ""),
. ,
(. 1.2).
Windows Store- -
,
( 30 -
). (. 1.3):
(Full Screen);
( ) (Snapped).
320 ;
Windows 8 17
. 1.2. Windows 8,
. 1.3.
(Filled).
, Windows Store-
. ,
1366768 . -
,
Windows Store-.
, Windows Store- -
(. 1.3), . -
, , -
(Portrait) ( . 1.3).
(Landscape) .
18 1
Windows Store- -
, , , .
.
, -
. API
, Win-
dows 8 , -
.
Windows Store- , , -
, , -
.
(App Bar) "-" (Charms).
, Windows Phone,
Windows 8 .
(. 1.4) ,
(
: ).
( , , -
), -
. ,
. , -
, , , , -
(, -
) ( , -
). :
, -
. , , -
,
, .
. 1.4.
Windows 8 19
. 1.5. "-"
"-" ,
(, , )
.
, -
"" (Tile) (. . 1.1). ,
. ,
, .
20 1
Web-, Push-.
Windows Store- -
.
, -
. 1.6.
. 1.6. ,
(Secondary Tiles) -
.
.
, , "-" -
, -
.
Windows Store- ,
.
Windows 8 21
Windows
API: (native) Win32 API
(managed) .NET Framework. ,
-
( WPF, Windows Presentation Foundation), -
, , -
.
, Windows, . . Win32 API -
. , -
COM (Component Object Model),
90- . . -
, , ,
-, , . . , ,
, . Windows 95 -
, Windows 8 -
.
, Windows, Microsoft ,
API, , (native) -
, . -
Windows Runtime (WinRT).
Windows Runtime , -
(API),
-
. , 50 ,
. . -
"" .
2.
WinRT COM, -
-
, .NET Framework. API, -
WinRT, ,
Windows Store-.
Windows Store- -
: C#, JavaScript, Visual Basic C++. ,
WinRT (
JavaScript), C#, ,
, C++ JavaScript.
WinRT "" -
. WinRT
22 1
, , ,
COM C#. .NET
Framework WinRT .
, JavaScript,
HTML 5, XAML (eXtensible Application
Markup Language ).
XAML WPF Silverlight. XAML -
Windows Phone. XAML Windows
Runtime, ,
Windows.
Windows Store- . -
, -
. , -
. , -
, ,
,
. , , -
. -
.
Windows 8 . 1.7.
. 1.7. Windows 8
Windows Store- C#
XAML. -
. C# , ,
http://bhv.ru/books/book.php?id=188312. XAML -
1.
Windows 8 23
Windows Store-
Windows Store- ()
, Microsoft,
.
Windows 8, Windows Phone, Xbox, Web- ,
http://outlook.com .
Windows 8 Microsoft
(Bauhaus), ( International Typographic
Style) (Motion Design).
, -
-
: , , ,
(. 1.8). , -
. , ,
.
, -
. -
, . -
. 1.8. Windows 8
24 1
, . . Win-
dows Store- , . ,
, , ,
.
(-
, , ,
- :
). ,
( ), -
. -
.
" " . -
. Windows Store- , -
. , ,
Windows 8.
Windows Store- - . ,
. , iPad iBooks,
. .
. -
Windows (. 1.9). ""
. 1.9.
Windows 8 25
, , -
( ).
, . -
, , (
). Windows 8, , -
. -
.
, ,
. Windows 8 ,
, . ,
, .
Windows 8,
Windows Runtime (WinRT),
Windows Store-.
Windows .
Windows 8 ,
, Windows.
Windows
Store-, .
Taa2
Windows,
Windows Store-, Windows--
MSDN (Microsoft Software Development Network):
http://msdn.microsoft.com/windows
:
http://msdn.microsoft.com/ru-ru/windows
Windows- SDK (Software
Development Kit), , . .
Windows Store- x86 x64
Windows 8. Windows Store-
Windows Windows RT ARM- .
Windows 8, (
) 90- . 90-
, . ,
Windows Store-,
Windows .
,
DreamSpark Premium,
Windows 8. .
, Windows 8, -
Windows Store-.
Microsoft
Visual Studio, . Microsoft
Express- Visual Studio 2012, Windows Store-
. Visual Studio Express 2012 for
Windows 8. Windows Store- -
27
. Blend , -
, VSM (Visual State Manager) -
. . Blend , ,
, Visual Studio.
, Blend , -
XAML C# (
HTML JavaScript JavaScript-). ,
Blend, Visual Studio.
Visual Studio Blend ,
. -
, Blend, Visual Studio -
, .
. 2.2 Visual Studio, . 2.3 Blend -
Windows Store-.
Visual Studio, Blend , -
. Visual Studio , TOOLS |
Options..., Environment | General, -
, Color theme. Visual Studio
. 2.4.
Blend , Tools | Options...,
Workspace, ,
Theme.
, -
Windows Store-. , Windows 8, -
90- .
Windows Store- .
Visual Studio Express 2012 for Windows 8 (
Visual
Studio 2012).
, Visual Studio 2012
Blend for Visual Studio.
, Win-
dows Store-, .
Taa3
Windows Store-
Visual Studio,
Windows Store-.
"Hello World", . -
,
, , ,
, -
c ARM- Windows RT.
Visual Studio
Visual Studio Express 2012 for Windows 8
Visual Studio 2012, .
, Express-.
,
. Windows Store-
, Visual Studio 2012 -
.
Visual Studio Express ,
(. 3.1). Visual Studio -
Windows Store-,
Visual Studio.
Windows Store-
Windows 8 -
Windows Store. , -
, ,
( ). -
, . . .
32 3
, -
.
Windows Store. ,
Windows Store . Windows Store, -
.
. 3.1.
I Agree.
, -
.
Microsoft (Microsoft
account, Windows LiveID).
(. 3.2) Sign in.
, -
(. 3.3).
,
Visual Studio Express STORE | Acquire Developer Licence... PROJECT |
Store | Acquire Developer Licence... Visual Studio.
Windows Store-. File |
New Project. New Project
Installed | Templates Visual C#, Windows
Store. New Project -
, -
Blank App (XAML). Name ,
HelloWorldApp, Location , -
. OK (. 3.4). -
Windows Store- 33
. 3.2. Microsoft
. 3.3. ,
, .
-
. (Tile) (
. 3.6, ).
Windows Store- 35
. 3.6.
Windows Store-, ,
. Solution
Explorer Visual Studio (. 3.7).
MainPage.xaml
XAML. , -
. App.xaml.cs,
.
MainPage.xaml. ,
. Windows 8 -
,
, -
. Windows Store-
. 4.
MainPage.xaml.cs (code-behind) C#
MainPage.xaml. - ,
xaml.cs.
36 3
MainPage.xaml.cs. ,
MVVM (Model-View-ViewModel),
, -
.
, , -
MVVM.
App.xaml Windows Store-
XAML.
. App.xaml -
. ,
, -
, .
( ) .
. 3.7.
Windows Store-
App.xaml 3.1.
3.1. App.xaml
<Application
x:Class="HelloWorldApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HelloWorldApp">
<Application.Resources>
<ResourceDictionary>
Windows Store- 37
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
StandardStyles.xaml.
.
App.xaml.cs (code-behind) C# App.xaml.
, , -
, , .
, App.xaml.cs -
.
StandardStyles.xaml -
. , App.xaml
. ,
, -
. StandardStyles.xaml
, ,
. -
.
Package.appxmanifest . -
, , (Tiles) -
(Splash Screen), , -
. . ,
XML-, ,
Visual Studio (. 3.8). -
Package.appxmanifest Solution Explorer.
Application UI, Capabilities, Declarations
Packaging, .
, , 3.2
Package.appxmanifest . ,
, Publisher, .
3.2. Package.appxmanifest
<Identity Name="f1e59aea-15c7-4515-89ba-1976f2499f4f"
Publisher="CN=v-sepuga"
Version="1.0.0.0" />
38 3
<Properties>
<DisplayName>HelloWorldApp</DisplayName>
<PublisherDisplayName>v-sepuga</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.2.1</OSMinVersion>
<OSMaxVersionTested>6.2.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="HelloWorldApp.App">
<VisualElements
DisplayName="HelloWorldApp"
Logo="Assets\Logo.png"
SmallLogo="Assets\SmallLogo.png"
Description="HelloWorldApp"
ForegroundText="light"
BackgroundColor="#464646">
<DefaultTile ShowName="allLogos" />
<SplashScreen Image="Assets\SplashScreen.png" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
AssemblyInfo.cs ,
(Assembly) .
HelloWorldApp_TemporaryKey.pfx -
, .
Logo.png, SmallLogo.png, StoreLogo.png -
, . -
, . .
. -
, . -
Windows Store- 39
. 3.8.
,
12.
,
.
SplashScreen.png , -
. ,
, -
. - .
References,
.NET-.
(Assemblies) (Frameworks), .
40 3
(. 3.9)
MainPage.xaml
Solution Explorer. , Windows
Store-, C#,
XAML (. 1). Visual Studio XAML-
, WYSIWYG (What You See Is What
You Get, " , "). Visual Studio -
Windows Store- -
. WYSIWYG,
, XAML-.
, -
, , ,
, ,
, , XAML-
.
. 3.9.
Windows Store- 41
, ,
Toolbox -
Properties, -
XAML- .
XAML-.
, XAML-
MainPage.xaml ( 3.3).
3.3.
<Page
x:Class="HelloWorldApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HelloWorldApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc=
"http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
</Grid>
</Page>
. -
, Basic Page. . XAML-
Page,
Grid (), .
ApplicationPageBackgroundThemeBrush, -
( ).
XAML- C#,
MainPage.xaml.cs. C#- , View Code -
XAML-.
C#- MainPage 3.4.
3.4. C# MainPage
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
42 3
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace HelloWorldApp
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
MainPage, -
( this.InitializeComponent). -
OnNavigatedTo, .
" !",
"Hello World".
Grid ( 3.5).
Grid -
, (HorizontalAlignment="Center"),
(VerticalAlignment="Center"). -
(. 3.10).
.
XAML-
Click Button. Click XAML-
(<New Event Handler>)
Windows Store- 43
(. 3.11).
. ,
Button_Click_1. -
. -
, -
.
. 3.11.
C#- ,
XAML- Navigate
to Event Handler. C#-,
( 3.6).
3.6.
{
this.InitializeComponent();
}
}
}
. -
. "Hello
World!" ( 3.7).
3.7.
. -
(. 3.12).
MessageDialog Windows.UI.Popups -
, , . -
( 3.8).
3.8.
. :
1, 2 3 ( 3.9). -
, .
(dlg.DefaultCommandIndex = 1).
-
<Enter>. , -
<Escape>.
.
, Button_Click_1 -
, async.
await ( async await 2).
, .
, ,
Id, .
3.9.
dlg.DefaultCommandIndex = 1;
dlg.CancelCommandIndex = 2;
.
. 3.13.
46 3
. 3.13.
, MessageDialog ,
. -
, .
.
,
, , , ,
. 1366768 -
, . -
. ,
-
, , ,
. .
, . . -
, . -
. Windows, -
, .
(Remote
Desktop, RDP).
-
Local Machine Simulator (. 3.14).
.
(. 3.15).
Windows,
, .
,
, .
Windows Store- 47
. 3.14.
. 3.15.
Start, -
"-"
.
13 .
.
(Minimize).
(Always on top).
,
(Mouse mode).
, (-
) (Basic touch mode).
(Pinch/zoom touch mode).
48 3
.
90 (Rotate clockwise (90 degrees)).
90 (Rotate counterclockwise
(90 degrees)).
(Change resolution).
(Set location).
(Copy screenshot).
(Screenshot settings).
(Help).
,
. -
. -
(. 3.16).
. 3.16.
, , 10,6 ,
. ,
( PPI, Pixels Per Inch). -
, ,
. , 9.
. , -
Windows Store- 49
, .
, , ,
, . ,
.
, ,
.
, , , .
-
Remote Tools for Visual Studio 2012. ,
. ,
.
, , . 3.17.
. 3.17.
Visual Studio.
Remote Machine . -
(. 3.18).
. -
.
,
, . ,
- . , -
. -
, .
, Visual Studio Express
STORE | Create App Packages... PROJECT | Store | Create App
Packages... Visual Studio. -
Windows Store. "" (No)
(. 3.19).
50 3
. 3.18.
. 3.19.
Windows Store- 51
Next, ( -
). Create.
appx, -
(. 3.20). appx -
. ZIP-,
, ,
HelloWorldApp_1.0.0.0_AnyCPU_Debug.appx zip
.
PowerShell ps1,
,
.
Windows PowerShell Microsoft,
.
PowerShell Windows 8.
. 3.20.
PowerShell Add-AppDevPackage.ps1. ,
.
52 3
Windows Store-
"Hello World".
Windows Store- .
Blank App,
, .
MainPage.xaml ,
C#. ,
.
, , .
,
.
Taa4
Win-
dows Store-: . 3 -
, MainPage.xaml,
. , Web-
. Web-
Windows Store- ( ).
, , -
(,
), . ,
Windows Store- Web-. Windows Store-,
JavaScript, . , -
C#, HTML- JavaScript XAML-
C#. CSS ,
XAML-.
"Hello World" ,
, ,
.
3 MainPage.xaml. -
App.xaml.cs. (-
4.1).
using System;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
54 4
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace HelloWorldApp
{
/// <summary>
/// , ,
/// Application
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// App
/// Singleton
///
///
/// main() WinMain()
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}
/// <summary>
/// ,
///
/// ,
/// ,
/// . .
/// </summary>
/// <param name="args"> .</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
Frame rootFrame = Window.Current.Content as Frame;
// ,
// ,
// ,
if (rootFrame == null)
{
// Frame,
//
rootFrame = new Frame();
if (args.PreviousExecutionState ==
ApplicationExecutionState.Terminated)
55
{
// TODO: ,
// Terminated
}
// Frame
//
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// ,
//
//
//
if (!rootFrame.Navigate(typeof(MainPage),
args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
// ,
Window.Current.Activate();
}
/// <summary>
///
/// (suspended)
/// ,
/// (tetminated)
/// (resumed)
/// ,
///
/// </summary>
/// <param name="sender"> .</param>
/// <param name="e"> .</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
// TODO:
//
deferral.Complete();
}
}
}
56 4
App, Application,
Package.appxmanifest . -
( , ). -
Main() .NET- (
main() WinMain() , C/C++).
( ) -
OnLaunched .
, . -
.
,
, OnLaunched Frame.
. -
.
( 4.2).
4.2.
rootFrame.Navigate(typeof(MainPage), args.Arguments);
Navigate -
, .
MainPage. .
, . -
Navigate , .
Solution Explorer -
Add | New Item.... ,
, (. 4.1).
Basic Page, SecondPage.xaml -
Add. . -
Yes .
Basic Page , Blank Page. Basic
Page , "", , -
(. 4.2).
XAML- SecondPage.xaml 4.3. ,
,
(VisualStateManager.VisualStateGroups) , .
57
. 4.1.
. 4.2. SecondPage.xaml
58 4
4.3. SecondPage.xaml
<common:LayoutAwarePage
x:Name="pageRoot"
...
>
<Page.Resources>
<x:String x:Key="AppName">My Application</x:String>
</Page.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<VisualStateManager.VisualStateGroups>
...
</VisualStateManager.VisualStateGroups>
</Grid>
</common:LayoutAwarePage>
,
Common (. . 4.2) .
( Basic Page), -
, .
, MainPage.xaml
SecondPage.xaml.
4.4.
4.4. SecondPage.xaml
, MainPage.xaml, Frame,
.
Frame .
, ,
HyperlinkButton ( 4.5).
4.5. HyperlinkButton
Click -
. 4.4.
Navigate Frame
(. 4.1).
4.1. Frame
/
GoBack
. ,
GoForward
. -
,
CanGoBack , ,
CanGoForward , ,
CurrentSourcePageType ,
60 4
SecondPage.xaml .
, Grid, -
SecondPage.xaml,
LayoutRootStyle ( 4.6)
4.6. Grid
StandardStyles.xaml
, , ( 4.7).
4.7. LayoutRootStyle
EntranceThemeTransition, -
.
, Grid, .
Windows 8
. ContentThemeTransition.
:
FadeInThemeAnimation/FadeOutThemeAnimation
PointerUpThemeAnimation/PointerDownThemeAnimation
RepositionThemeAnimation/RepositionThemeTransition
PopInThemeAnimation/PopOutThemeAnimation/PopupThemeTransition
EdgeUIThemeTransition
PaneThemeTransition
AddDeleteThemeTransition
61
DragItemThemeAnimation/DropTargetItemThemeAnimation/ DragOverThemeAnimation
SwipeHintThemeAnimation/SwipeBackThemeAnimation
.
.
Navigate Frame. -
, int, string, char, Guid
. . , , ,
, . , -
.
4.8 .
4.8.
, -
OnNavigatedTo , ( 4.9).
SecondPage.xaml.
4.9. ,
base.OnNavigatedTo(e);
}
OnNavigatedTo (
). OnNavigateTo
base.OnNavigatedTo(e). , -
.
, . (override) -
, ,
.
SecondPage LayoutAwarePage, -
, .
.
. .
Basic Page
LayoutAwarePage,
. Blank App,
LayoutAwarePage -
. , Grid App Split App,
.
Windows Store- ,
Windows-. -
, Windows
, .
, .
, . -
, ,
.
.
Windows Store- 10.
, (, , ) -
- . , . .
5 . -
, ,
,
.
63
.
SuspensionManager, -
SecondPage.xaml. SuspensionManager
. SuspensionManager -
. -
, SuspensionManager -
.
SuspensionManager App.xaml.cs ( 4.10).
4.10. SuspensionManager
if (rootFrame == null)
{
rootFrame = new Frame();
SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
if (args.PreviousExecutionState ==
ApplicationExecutionState.Terminated)
{
try
{
await SuspensionManager.RestoreAsync();
}
catch (SuspensionManagerException)
{
//
}
}
// Frame
//
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
Window.Current.Activate();
}
64 4
await SuspensionManager.SaveAsync();
deferral.Complete();
}
, -
. ,
.
, -
. , .
Basic Page LoadState SaveState ( 4.11), -
,
SuspensionManager.
. -
.
SuspensionManager ( 4.12).
4.12. SuspensionManager
SuspensionManager.SessionState.Add("", "");
. -
.
, , -
, , .
65
SecondPage.xaml
( 4.13).
4.13.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Row="1">
<TextBox x:Name="txtMain" Width="250"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Grid>
<VisualStateManager.VisualStateGroups>
.
. , -
.
,
, NavigationCacheMode.
Enabled ( 4.14),
, , .
,
.
4.14. NavigationCacheMode
public SecondPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Enabled;
}
66 4
NavigationCacheMode Required,
.
NavigationCacheMode , -
. -
.
NavigationCacheMode,
( , -
) . -
, LoadState SaveState ( 4.15).
.
4.15.
if (pageState.ContainsKey("text"))
{
txtMain.Text = pageState["text"] as string;
}
}
,
Debug Location
Visual Studio (. 4.3). ,
VIEW | Toolbars | Debug Location.
,
.
HyperlinkButton NavigateUri
, ( 4.16). -
, .
4.16. HyperlinkButton
<HyperlinkButton NavigateUri="http://twitter.com/spugachev"
Content="@spugachev"/>
, . . -
http. , -
. -
(
). ,
mailto, FTP- ftp.
Launcher ( 4.17).
4.17.
Launcher.LaunchUriAsync(new Uri("http://twitter.com/spugachev"));
( 4.18).
4.18.
TreatAsUntrusted ,
.
DisplayApplicationPicker ,
.
, , ,
Windows
Store. PreferredAppli-
cationDisplayName PreferredApplicationPackage-
FamilyName. -
, .
Launcher .
LaunchFileAsync. ,
.
, .
Windows Store--
. -
Launcher.
17.
App.xaml.cs, .
-
. , , ,
Windows Store-
.
.
.
.
Taa5
, .
,
. ( -
), -
.
XAML, -
1, .
ApplicationPageBackgroundThemeBrush ( 5.1).
5.1.
. -
, . , , -
ApplicationPageBackgroundThemeBrush, ,
. . -
, .
Windows Phone, ,
Windows Phone Windows 8 . Win-
dows Phone , Windows 8 -
.
70 5
Grid App. , -
Grid App, ,
GroupedItemsPage.xaml.
, (. 5.1).
. 5.1. ,
. App.xaml. -
RequestedTheme Light
( 5.2).
5.2.
<Application
x:Class="ThemeApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ThemeApp"
xmlns:localData="using:ThemeApp.Data"
RequestedTheme="Light">
(. 5.2). -
.
71
. 5.2. ,
App ( 5.3).
5.3.
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
RequestedTheme = ApplicationTheme.Light;
}
Visual Studio ,
( ).
Device, Visual Studio. ,
DESIGN | Device Window . Device -
(. 5.3).
Device
.
72 5
. 5.3. Device
TextBlock ( 5.4).
5.4.
, (-
5.5).
5.5.
, -
( , , ). -
, , -
, .
15 , . . .
,
BasicTextStyle ( 5.6).
5.6.
. 5.4 .
, -
.
. 5.4.
:
PageHeaderTextStyle TitleTextStyle
PageHeaderTextStyle SubtitleTextStyle
PageSubheaderTextStyle ItemTextStyle
SnappedPageHeaderTextStyle BodyTextStyle
HeaderTextStyle CaptionTextStyle
SubheaderTextStyle BasicTextStyle
GroupHeaderTextStyle BaselineTextStyle.
. . 5.5 -
, . , ,
, .
StandardStyles.xaml. -
,
.
. -
, Edit Style | Apply
Resource (. 5.6).
.
( 5.7).
5.7.
Arial 24
</Run>
</TextBlock>
5.7
. 5.7.
. 5.5. ,
- ,
RichTextBlock ( -
RichEditBox), TextBlock.
RichTextBlobk , .
, -
.
StandardStyles.xaml, ,
MSDN.
75
. 5.6.
. 5.7.
Windows Store-. -
.
App.xaml .
76 5
, ApplicationPageBackgroundThemeBrush
ApplicationForegroundThemeBrush, . , -
. StandardStyles.xaml
, .
, ,
HeaderTextStyle, , .
. -
Windows Store-.
Taa6
(Application Bar)
Windows Store-.
, . ,
, . ,
Application, - , "
", ,
.
, - .
,
.
.
" " "" -
. .
, <Windows>+<Z>,
.
. -
, -
, .
,
.
, , , . -
, . -
, .
. -
, Internet Explorer
( , ).
. 6.1 Internet Explorer , . 6.2 .
78 6
Internet Explorer -
. .
, -
(. 6.3). .
. 6.3.
C
BottomAppBar TopAppBar ( 6.1). -
AppBar.
6.1.
<Page
...
>
<Page.TopAppBar>
<AppBar x:Name="topAppBar" Padding="10,0,10,0">
<!-- -->
</AppBar>
</Page.TopAppBar>
<Page.BottomAppBar>
80 6
<Grid
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
</Grid>
</Page>
( 6.2). Grid
( ).
6.2.
.
,
Windows Store-, (-
).
AppBarButtonStyle.
,
AutomationProperties.Name ( 6.3).
6.3.
. 6.4.
AppBarButtonStyle
. 6.4 , AppBarButtonStyle.
StandardStyles.xaml . -
. .
,
StandardStyles.xaml ( 6.4).
6.4.
. 6.5. ,
. ,
AutomationProperties.Name.
. 6.5.
82 6
,
StandardStyles.xaml . -
. 6.6.
. 6.6 .
.
. 6.6.
83
IsSticky
. -
(
. .), IsSticky ( 6.5).
6.5. IsSticky
, , -
IsOpen, .
-
.
. ,
(. 6.7).
Popup, -
.
.
. 6.7.
84 6
Popup Flyout Windows Store-
, JavaScript.
(-
6.6). .
, (PopupThemeTransition).
6.6.
popup.Child = panel;
popup.HorizontalOffset = point.X;
popup.VerticalOffset = Window.Current.CoreWindow.Bounds.Bottom -
bottomAppBar.ActualHeight panel.Height 4;
popup.IsOpen = true;
}
. 6.8.
(Child),
(HorizontalOffset VerticalOffset) IsOpen true.
85
. 6.8.
,
, . -
PopupMenu ( 6.7).
6.7.
await popupMenu.ShowAsync(point);
}
. 6.9.
, MessageDialog, -
. .
-
. , -
.
86 6
. 6.9.
Windows Store--
. .
.
, -
, , -
StandardStyles.xaml.
.
. Popup PopupMenu.
Taa7
RSS-
Grid App
5 Grid App.
, , , -
, . RSS-
Grid App.
RSS- . http://blogs.msdn.com/
b/somasegar/.
. RSS-
. 7.1.
. 7.1. RSS-
88 7
. 7.2.
SampleDataSource.cs
. -
.
.
SampleDataSource.cs :
SampleDataSource
SampleDataGroup
SampleDataItem
Grid App , , -
. ,
. -
SampleDataGroup,
SampleDataItem.
, -
AllGroups SampleDataSource.
SampleDataSource ,
.
SampleDataSource.
_allGroups AllGroups , GetGroup
RSS- Grid App 89
GetItem( SampleDataSource)
( 7.1).
7.1. SampleDataSource
RSS.
SyndicationClient
Windows.Web.Syndication. RSS-
Atom-, ( 7.2). ,
SyndicationClient , ,
.
RSS, .
HTTP, HttpClient. , -
HTTP, Socket API.
90 7
Windows 8 . -
Web-.
.
7.2. RSS-
SampleDataSource AddGroupForFeedAsync,
( 7.3).
7.3.
AllGroups.Add(feedGroup);
return true;
}
SampleDataGroup -
AllGroups.
. (-
) ,
HTML- . -
GetImageFromPostContents ( 7.4). -
HTML- src href, -
png, jpg jpeg (, <img src="image.jpg" />).
-
.
RSS- Grid App 91
7.4.
return matches.Cast<Match>()
.Where(m =>
{
Uri url;
if (Uri.TryCreate(m.Groups[1].Value, UriKind.Absolute, out url))
{
string ext = Path.GetExtension(url.AbsolutePath).ToLower();
if (ext == ".png" || ext == ".jpg"
|| ext==".jpeg") return true;
}
return false;
})
.Select(m => m.Groups[1].Value)
.FirstOrDefault();
}
AddGroupForFeedAsync ,
SampleDataItem ( 7.5). -
,
.
7.5.
feedGroup.Items.Add(dataItem);
}
AllGroups.Add(feedGroup);
return true;
}
, . -
.
GroupedItemsPage.xaml. -
( 7.6).
7.6.
GroupedItemsPage.xaml
//
await SampleDataSource.AddGroupForFeedAsync(
"http://blogs.msdn.com/b/mikcher/rss.aspx");
await SampleDataSource.AddGroupForFeedAsync(
"http://blogs.msdn.com/b/stasus/rss.aspx");
await SampleDataSource.AddGroupForFeedAsync(
"http://blogs.msdn.com/b/kichinsky/rss.aspx");
}
RSS- Grid App 93
, . , -
, Grid App, .
. , . 7.1. -
GroupDetailPage.xaml (. 7.3).
- .
ItemDetailPage.xaml (. 7.4).
. 7.3. GroupDetailPage.xaml
. 7.4. ItemDetailPage.xaml
94 7
ItemDetailPage.xaml HTML-
. , . . HTML- -
. . -
WebView, , -
HTML-. HTML-
.
, ,
.
, -
1.
LayoutAwarePage.
DefaultViewModel, -
(Dependency Property) DefaultViewModelProperty ( 7.7).
7.7. DefaultViewModel
...
set
{
this.SetValue(DefaultViewModelProperty, value);
}
}
...
}
RSS- Grid App 95
this.DefaultViewModel["Groups"] = SampleDataSource.AllGroups;
7.9.
<common:LayoutAwarePage
x:Name="pageRoot"
x:Class="RssApp.GroupedItemsPage"
DataContext="{Binding DefaultViewModel,
RelativeSource={RelativeSource Self}}"
...
mc:Ignorable="d">
, " ",
. CollectionViewSource,
, .
CollectionViewSource Groups DefaultViewModel
( 7.10).
7.10. CollectionViewSource
<Page.Resources>
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding Groups}"
IsSourceGrouped="true"
ItemsPath="TopItems"/>
</Page.Resources>
GridView, -
( 7.11). GridView -
. -
, . 7.1.
96 7
7.11. GroupedItemsPage.xaml
<common:LayoutAwarePage
x:Name="pageRoot"
x:Class="RssApp.GroupedItemsPage"
DataContext="{Binding DefaultViewModel,
RelativeSource={RelativeSource Self}}"
...
mc:Ignorable="d">
<Page.Resources>
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding Groups}"
IsSourceGrouped="true"
ItemsPath="TopItems"/>
</Page.Resources>
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemGridView"
AutomationProperties.Name="Grouped Items"
Grid.RowSpan="2" Padding="116,137,40,46"
ItemsSource=
"{Binding Source={StaticResource groupedItemsViewSource}}"
ItemTemplate="{StaticResource Standard250x250ItemTemplate}"
SelectionMode="None" IsSwipeEnabled="false"
IsItemClickEnabled="True" ItemClick="ItemView_ItemClick">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
...
</DataTemplate>
</GroupStyle.HeaderTemplate>
RSS- Grid App 97
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical"
Margin="0,0,80,0"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
</GridView>
...
</Grid>
</common:LayoutAwarePage>
GridView, ListView FlipView
Windows Store-
GridView ListView, -
, ItemsControl -
. GridView -
, ListView ( ).
, , . .
GridView
(. . 7.1). GridView , -
. , GridView -
. . 8.1 -
GridView .
. 8.1. GridView
GridView, ListView FlipView 99
. 8.2
ListView, ,
GridView . 8.1.
GridView ListView
.
GridView ,
ListView (Snapped).
ListView
GridView,
, , -
.
. 8.2.
ListView
GridView
GridView.
Blank App ControlsApp.
MainPage.xaml GridView
gvMain ( 8.1).
8.1. GridView
<Page
...
>
100 8
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
</GridView>
</Grid>
</Page>
, GridView. -
Person,
, : FirstName, LastName Age
( 8.2).
8.2. Person
MainPage.xaml Person,
ObservableCollection<T>. -
, (List<T>),
. -
, -
, ListView GridView, -
-
. ObservableCollection<T> ,
.
, . .
GridView. ,
.
, ItemsControl,
(Items) . , -
Items ( 8.3).
GridView, ListView FlipView 101
8.3. Items
gvMain.Items.Add(
new Person { LastName = "", FirstName = "", Age = 31 });
GridView ItemsSource (-
8.4).
7 ItemsSource
XAML-:
ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
8.4. GridView
public MainPage()
{
this.InitializeComponent();
gvMain.ItemsSource = _persons;
}
}
, .
_persons Person, .
. GridView, ,
(. 8.3).
ToString Person.
, .
"ControlsApp.Person".
102 8
. 8.3. GridView
GridView,
(ItemTemplate). -
Avatar.png,
. , -
7. ( 8.5).
160160 .
8.5.
ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="/Assets/Avatar.png"
Stretch="UniformToFill"/>
</Border>
<StackPanel VerticalAlignment="Bottom"
Background="{StaticResource
ListViewItemOverlayBackgroundThemeBrush}">
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
-
Person.
. GridView -
(. 8.4). ,
, GridView
, .
, GridView
.
. 7 -
, . ,
.
, : , .
PersonGroup ( 8.6).
104 8
. 8.4.
8.6. PersonGroup
public PersonGroup()
{
Persons = new ObservableCollection<Person>();
}
}
GroupName,
Persons.
GridView CollectionViewSource.
( 8.7).
8.7. CollectionViewSource
<Page
...
>
GridView, ListView FlipView 105
<Page.Resources>
<CollectionViewSource
x:Name="cvsMain"
IsSourceGrouped="true"
ItemsPath="Persons"/>
</Page.Resources>
...
IsSourceGrouped true, . .
, ItemsPath Persons,
Persons PersonGroup .
CollectionViewSource GridView ( 8.8).
CollectionViewSource. -
( 8.9).
8.9.
public MainPage()
{
this.InitializeComponent();
_groups.Add(developers);
_groups.Add(designers);
_groups.Add(managers);
cvsMain.Source = _groups;
}
}
, (. . 8.4).
( 8.10), , -
. -
.
.
8.10.
. , -
, , (. 8.5).
-, .
. -, -
.
,
GridView, ListView FlipView 107
(GroupStyle.Panel). -
VariableSizedWrapGrid.
, ,
GridView ( 8.11). ,
( ),
80 (Margin="0,0,80,0").
. 8.5.
8.11.
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
...
</DataTemplate>
</GroupStyle.HeaderTemplate>
108 8
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical"
Margin="0,0,80,0"
ItemWidth="160" ItemHeight="160"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
VariableSizedWrapGrid (),
160160 (ItemWidth="160" ItemHeight="160").
,
(. 8.5). ,
.
(
GridView). , , ,
, . -
VirtualizingStackPanel ,
( -
) ( 8.12).
,
.
VariableSizedWrapGrid.
8.12. GridView
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
. , (. 8.6).
VirtualizingStackPanel
(. 8.7).
. 8.7 , , -
. , , -
, ,
.
GridView, ListView FlipView 109
. 8.6.
. 8.7.
GridView
110 8
GridView
, GridView -
VariableSizedWrapGrid ( , -
). 160160 .
,
320 .
Person HorizontalSize VerticalSize
, ( 8.13). -
, .
Person
( 8.14).
8.14. Person
.
GridView
, GridView.
PrepareContainerForItemOverride,
( -
). VariableGridView ( 8.15).
8.15. VariableGridView
if (personItem != null)
{
element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty,
personItem.HorizontalSize);
element.SetValue(VariableSizedWrapGrid.RowSpanProperty,
personItem.VerticalSize);
}
base.PrepareContainerForItemOverride(element, item);
}
}
VariableSizedWrapGrid.ColumnSpanProperty
VariableSizedWrapGrid.RowSpanProperty -
, Person.
GridView
MainPage.xaml VariableGridView ( 8.16).
<Page
x:Class="ControlsApp.MainPage"
...
112 8
xmlns:local="using:ControlsApp"
...
>
<Page.Resources>
...
</Page.Resources>
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<local:VariableGridView x:Name="gvMain"
Grid.Row="1" Padding="116,37,40,46"
ItemsSource="{Binding Source={StaticResource cvsMain}}">
...
</local:VariableGridView>
</Grid>
</Page>
(. 8.8).
. 8.8. GridView
GridView, ListView FlipView 113
,
. ,
25601440 -
(. 8.9).
. 8.9. 25601440
.
( ).
VariableSizedWrapGrid
MaximumRowsOrColumns ( 8.17).
8.17. MaximumRowsOrColumns
<GroupStyle.Panel>
<ItemsPanelTemplate>
114 8
GridView
GridView
Person. GridView , -
- . . -
, - ,
, ( ).
, .
. ,
DataTemplateSelector, .
, -
. , ClassA ClassB,
. -
. 8.18.
8.18.
if (item is ClassA)
{
return (DataTemplate)Application.Current.Resources[
"classATemplate"];
}
if (item is ClassB)
{
return (DataTemplate)Application.Current.Resources[
"classBTemplate"];
}
GridView, ListView FlipView 115
return (DataTemplate)Application.Current.Resources[
"basicTemplate"];
}
}
SampleTemplateSelector, GridView (-
8.19).
8.19. SampleTemplateSelector
<Page
x:Class="ControlsApp.MainPage"
...
xmlns:local="using:ControlsApp"
...
>
<Page.Resources>
...
<local:SampleTemplateSelector x:Key="templateSelector"/>
</Page.Resources>
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
...
<GridView
ItemTemplateSelector="{StaticResource templateSelector}">
</GridView>
...
</Grid>
</Page>
(Semantic Zoom)
(Semantic Zoom) ,
Windows 8, Windows Store-
.
:
116 8
();
(); , -
.
( ,
), -
<Ctrl>, <+> <> -
<Ctrl>. ,
.
, -
ISemanticZoomInformation. , GridView
ListView .
(. 8.10).
. 8.10.
( ) .
(
Windows-), . -
, (. 8.11).
.
, .
GridView, ListView FlipView 117
. 8.11.
, -
.
SemanticZoom, ZoomedInView -
ZoomedInView ( 8.20).
8.20. SemanticZoom
<SemanticZoom>
<SemanticZoom.ZoomedInView>
<!-- -->
</SemanticZoom.ZoomedInView>
<SemanticZoom.ZoomedOutView>
<!-- -->
</SemanticZoom.ZoomedOutView>
</SemanticZoom>
GridView .
GridView
. GridView
gvZoomedOut ( 8.21), . .
.
118 8
8.21.
GridView ( ).
CollectionViewSource cvsMain.
, .
MainPage gvZoomedOut ( 8.22).
GridView, ListView FlipView 119
8.22. gvZoomedOut
public MainPage()
{
this.InitializeComponent();
...
cvsMain.Source = _groups;
gvZoomedOut.ItemsSource = cvsMain.View.CollectionGroups;
}
, . -
. ""
(. 8.12).
. 8.12.
: , , -
( <Ctrl>)
.
(. 8.13).
, -
.
, . . .
, , , -
.
. -
. -
.
120 8
. 8.13.
ListView
ListView , GridView.
ListView, ,
GridView. :
( 8.23).
8.23. ListView
ListView . 8.14.
ListView GridView. -
SelectionMode,
. 8.1.
8.1. SelectionMode
None
Single
122 8
8.1 ()
Multiple
Extended ,
, , ,
<Shift>,
. 8.14.
ListView
GridView, ListView FlipView 123
FlipView
, -
, FlipView .
.
FlipView , GridView ListView ItemsControl,
-
. FlipView
, -
.
FlipView
- . FlipView -
-.
FlipView People.
, GridView ( 8.24).
8.24. FlipView
FlipView
(. 8.15). . 8.15 -
.
FlipView . FlipView
.
. 8.15. FlipView
124 8
1, Windows Store-
( . 9.1):
(Full Screen);
( c) (Snapped).
320 ;
(Filled).
,
1366768 . , Windows Store-
.
.
, , -
, -
.
. 9.1.
126 9
,
8.
, , -
. - ,
320 ,
. .
, GridView, -
ListView.
, .
GridView SemanticZoom (-
9.1). , 8.
9.1. MainPage.xaml
<Page
...
>
...
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
ListView , . . Visibility
Collapsed.
ListView lvMain -
SemanticZoom semanticZoom.
.
Value ApplicationView, :
Snapped
Filled
FullScreenLandscape
FullScreenPortrait
, ,
. ,
, 9.2.
9.2.
switch (ApplicationView.Value)
{
case ApplicationViewState.Snapped:
{
}
break;
case ApplicationViewState.Filled:
{
}
break;
case ApplicationViewState.FullScreenLandscape:
{
}
break;
case ApplicationViewState.FullScreenPortrait:
{
}
break;
}
128 9
. -
.
( Window.Current.SizeChanged). , -
, ,
. -
, .
( 9.3).
9.3.
public MainPage()
{
this.InitializeComponent();
...
Window.Current.SizeChanged += Current_SizeChanged;
}
. -
- (. 9.2).
(Bing
Weather), Filled.
Visual
Studio. Device.
View (. 9.3).
129
. 9.2.
130 9
. 9.3.
9.4.
<common:LayoutAwarePage
... >
...
<Grid Style="{StaticResource LayoutRootStyle}">
...
<GridView x:Name="itemGridView"
... >
...
</GridView>
131
<ListView x:Name="itemListView"
... >
...
</ListView>
<Grid>
...
<Button x:Name="backButton" Click="GoBack"
IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}"
Style="{StaticResource BackButtonStyle}"/>
<TextBlock x:Name="pageTitle" Text="{StaticResource AppName}"
Grid.Column="1" IsHitTestVisible="false"
Style="{StaticResource PageHeaderTextStyle}"/>
</Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ApplicationViewStates">
<VisualState x:Name="FullScreenLandscape"/>
<VisualState x:Name="Filled"/>
<VisualState x:Name="FullScreenPortrait">
<Storyboard>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="backButton"
Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{StaticResource PortraitBackButtonStyle}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="itemGridView"
Storyboard.TargetProperty="Padding">
<DiscreteObjectKeyFrame KeyTime="0"
Value="96,137,10,56"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="backButton"
Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{StaticResource SnappedBackButtonStyle}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="pageTitle"
132 9
Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{StaticResource
SnappedPageHeaderTextStyle}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="itemListView"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0"
Value="Visible"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="itemGridView"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0"
Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</common:LayoutAwarePage>
Visual State
Manager (VSM, ). -
XAML-. ,
, VSM .
LayoutAwarePage
VSM , -
. VSM .
VSM , LayoutAwarePage,
VSM LayoutAwarePage.
LayoutAwarePage
VisualStateManager.GoToState.
Device Visual Studio -
.
, VSM ,
. -
(Storyboard),
. 9.5
.
133
9.5.
<VisualState x:Name="Snapped">
<Storyboard>
...
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="itemListView"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
</ObjectAnimationUsingKeyFrames>
...
</Storyboard>
</VisualState>
9.5 ListView
itemListView. Visibility,
Visible.
(
) , . . VSM ,
.
FullScreenPortrait ListView -
.
Visual State Manager
, ,
, , -
. Visual State Manager ,
.
,
(PPI, Pixels Per Inch ). , 27--
25601440.
10- , 1024768, -
.
25601440, 1024768, , -
,
(PPI
, ).
Windows 8 Windows Store- , -
-
134 9
PPI. Windows ,
PPI
. . -
.
:
100% ;
140% 19201080 PPI 174;
180% 25601440 PPI 240.
, , - -
. -
, XAML, -
.
, . , -
.
, PNG
JPEG. .
. -
, -
. -
. -
.
-
.
. ,
:
logo.scale-100.png 100100;
logo.scale-140.png 210210;
logo.scale-180.png 270270.
XAML- ( 9.6).
9.6.
!
, logo.png.
. , -
, .
135
, -
. :
scale-100\logo.png;
scale-140\logo.png;
scale-180\logo.png.
-
. XAML- ,
, .
(Snapped) ,
. ,
, -
.
-
Visual State Manager (VSM). LayoutAwarePage
VSM.
, -
Windows Store- .
.
, .
Taa10
Win-
dows Store-, -
, .
, -
, -
,
. -
Windows.
,
-
: , -
,
.
, -
,
, -
. -
,
.
, Windows Store- ,
. Windows Store-
.
. 137
-. -
-.
, -
, - .
, , -
,
. ,
(Suspended). , .
,
(Terminated). Win-
dows Store- . 10.1.
. ,
4, -
.
, , -
. , ,
, . .
.
App.xaml.cs. OnLaunched,
OnSuspending ( 10.1). -
, 4.
10.1. App.xaml.cs
.
PreviousExecutionState args
. -
PreviousExecutionState:
NotRunning -
, (log off),
.
Running ,
, , , -
(Secondary tile).
Suspended -
.
Terminated -
. -
, Suspended,
Terminated.
ClosedByUser .
OnLaunched .
, , -
OnLaunched.
OnSearchActivated ( 10.2).
10.2. ""
OnSearchActivated ,
, -
"-".
13.
, OnLaunched OnSearchActivated
. -
.
.
. 139
,
Windows Store- ( ),
,
, . -
, , /
, , -
, . . .
, , -
.
/
BackgroundDownloader,
BackgroundUploader. ()
, , (), -
.
HTTP HTTPS ( GET, POST)
() HTTP HTTPS (
POST) . -
.
, ,
.
Windows Store- Blank App
DownloadApp. MainPage.xaml
btnStartDownload tbDownloadProgress ( 10.3).
10.3. MainPage.xaml
btnStartDownload. -
.
, ,
. -
. 10.3.
140 10
10.3.
BackgroundDownloader
( DownloadOperation). -
( 10.3).
, StartAsync. -
10.4.
10.4.
public MainPage()
{
this.InitializeComponent();
}
StartAsync .
, .
, ,
( 10.5).
10.5. Task
DownloadProgress.
.
, . .
.
AttachToProccesses,
, BackgroundDownloader.GetCurrentDownloadsAsync. -
.
10.6.
public MainPage()
{
this.InitializeComponent();
AttachToProcesses();
}
142 10
if (download != null)
{
var task = download.AttachAsync().AsTask(
_cancellationTokenSource.Token,
new Progress<DownloadOperation>(DownloadProgress));
}
}
catch (Exception ex)
{
//
}
}
-
, .
Windows Store- .
, . -
, -
(, -) (-
, ). -
( )
( ) .
(Assembly, DLL-
). ,
(, . .).
, ,
. , -
, . -
,
WNS (Windows Push Notification Services
Windows). Push- , -
. 143
(
).
, (Lock Screen) .
,
(. 10.2).
. 10.2. ( Windows
http://blogs.msdn.com/b/b8/archive/2012/06/14/building-the-mail-app.aspx)
, ,
( ), , -
, -
.
. ,
. -
,
(. 10.3).
, ,
, .
, -
(. 10.1).
. 10.1 , . ,
, ,
. . ,
144 10
, 2 -
15 . 15
.
(. 10.2).
. 10.3. ,
10.1.
, 2 15
, 1 2
10.2.
ControlChannelTrigger , -
. , ,
, ,
TCP-
. ,
. 145
10.2 ()
MaintenanceTrigger
TimeTrigger . TimeTrigger ,
.
MaintenanceTrigger ,
.
. -
( 15 .), .
,
PushNotificationTrigger , Push- Raw
( 11). -
SystemEventTrigger .
,
. 10.3 ,
SystemEventTrigger. , , -
, .
10.3. SystemEventTrigger
InternetAvailable
NetworkStateChange . ,
Wi-Fi 3G
OnlineIdConnectedStateChange ,
ServicingComplete
LockScreenApplicationAdded
LockScreenApplicationRemoved
ControlChannelReset*
SessionConnected*
SmsReceived -
TimeZoneChange , ,
UserAway*
UserPresent*
. . -
, .
146 10
, . -
InternetAvailable.
. 10.4.
10.4.
InternetAvailable
InternetNotAvailable
SessionConnected
SessionDisconnected
UserNotPresent
UserPresent
, . -
, -
IBackgroundTask.
Blank App TasksApp.
, (solution) -
Windows Runtime Component. Solution Explorer -
Solution TasksApp (1 project) Add | New
Project... Windows
Runtime Component TasksComponent.
Windows Store- .
References Add
Reference... TasksComponent.
Solution Explorer
. 10.4.
, , -
, -
.
TasksComponent (-
10.7).
10.7.
{
var deferral = taskInstance.GetDeferral();
try
{
//
}
finally
{
deferral.Complete();
}
}
}
. 10.4.
Solution Explorer
SampleBackgroundTask
. Package.appxmanifest
Declarations Background Tasks.
System Event, (Entry point) -
TasksComponent.SampleBackgroundTask (. 10.5).
-
. MainPage.xaml , -
.
BackgroundTaskBuilder. -
. , -
( 10.8).
148 10
. 10.5.
10.8.
builder.Name = "SampleBackgroundTask";
builder.TaskEntryPoint = "TasksComponent.SampleBackgroundTask";
builder.SetTrigger(timerTrigger);
SystemTrigger ,
. (TimeZoneChange).
. 149
BackgroundTaskBuilder -
, (-
10.9).
10.9.
builder.Name = "SampleBackgroundTask";
builder.TaskEntryPoint = "TasksComponent.SampleBackgroundTask";
builder.SetTrigger(timerTrigger);
Completed BackgroundTaskRegistration -
.
,
( 10.10).
10.10.
, ,
. . -
. , -
Visual Studio
Debug Location (. 10.6). ,
(Suspend),
(Resume), (Suspend
150 10
and shutdown),
SampleBackgroundTask.
Debug Location , VIEW |
Toolbars | Debug Location.
Windows Store-, -
Windows-.
Windows Store- , -
.
/ BackgroundDownloader
BackgroundUploader . ,
, , -,
( ).
,
. -
. , -
,
.
Taa11
? ,
, -
- -
. , -
, .
.
(Toast Notification).
(Tiles) .
, (Push-
).
,
Push-. 12.
-
.
. : -
, -
, - .
:
7
.
25 .
152 11
.
.
, (. 11.1).
11.1.
ToastImageAndText01
ToastImageAndText02
ToastImageAndText03
ToastImageAndText04
ToastText01
ToastText02
ToastText03
ToastText04
, -
, . 11.1.
153
. 11.1.
(, Push-
), -
. Application UI , Notifications
Yes Toast capable (. 11.2).
XML-,
. ToastText01
( 11.1).
<toast>
<visual>
<binding template="ToastText01">
<text id="1">
</text>
</binding>
</visual>
</toast>
XML- ToastNotification (-
) ToastNotifier (-
11.2).
154 11
. 11.2.
11.2.
, , . .
.
, 10
( 11.3).
11.3.
.
,
, , , . .
( ), -
. ,
, , -
(Push-). -
, (, , -
). -
.
Push-
Push- (Push Notification)
( ). "" (push) ,
(, pull) . Windows-
156 11
-
. Windows Store-, ,
, . Push-
.
. Push- -
.
, -
. Push- -
Windows (WNS, Windows Push Notification Services).
( ) -
WNS, ,
,
.
Push- Windows Store-
,
. ,
, WNS -
. WNS
.
Push-:
Toast . ,
;
Tile Badge , .
12;
Raw . Raw-
, "" -
, -
. Raw- ,
.
Raw- , , Raw-
, , -
.
WNS-.
Windows Store
WNS, ,
.
Windows Store, -
. ,
.
157
MSDN :
http://msdn.microsoft.com/ru-ru/library/windows/apps/hh465407.aspx
, "" , -
Windows Store, ,
, Windows Store.
""
Windows Store.
Store | Associate with the Store Visual Studio Express
Project | Store | Associate with the Store Visual Studio.
, -
:
SID (Package Security Identifier / )
ms-app://s-1-15-2-347940726-2465832990-910876698-369105280-2399447978-
997722633-4228783870.
Client secret / ( 1)
-a0o4J2-drcAxBUKeBA7cT06orFATHJw.
. ,
Push- .
Windows Store- .
,
, -
. -
.
- . , -
,
. WNS
, .
, ,
.
Push-
Windows Store -
, Push-.
Push- .
, -
. Windows Store- -
URI, ( ) -
.
PushNotificationChannelManager ( 11.4).
158 11
11.4. URI
URI:
https://db3.notify.windows.com/?token=AgUAAAC0wm%2frjhZ0ciivfeaM%2bn0c2vh8%2fuJ
2NFN6PdwAzkv8KkWrwDvw7qEix%2fzkZsvbQJYt5mR45K7MP2ExP%2fSF4WF8zUuuzlDH6UYoMnwj2A
KA4wadN%2bc9qGUEBYvBcVO4Qt0%3d
URI .
.
URI
PushNotificationChannel, Push--
, .
.
, C#.
. -
, , , ASP.NET MVC, PHP,
Python, Ruby, Java, node.js . .
, ,
XML-. -
11.5.
11.5.
sid secret , -
Windows Store, url , . -
, sid secret
, , , , -
, -
.
PostToWns, .
,
WNS-. WNS-
OAuthToken ( 11.6).
11.6.
WNS-
[DataContract]
public class OAuthToken
{
[DataMember(Name = "access_token")]
public string AccessToken { get; set; }
[DataMember(Name = "token_type")]
public string TokenType { get; set; }
}
System.Runtime.Serialization.dll.
WNS- (-
11.7).
11.7. WNS-
string response;
using (var client = new WebClient())
{
client.Headers.Add("Content-Type",
"application/x-www-form-urlencoded");
response = client.UploadString(
"https://login.live.com/accesstoken.srf", body);
}
return GetOAuthTokenFromJson(response);
}
161
System.Web.dll. -
WNS , . .
.
, . -
, XML-,
, .
PostToWns:
wns/toast ;
wns/badge ;
wns/tile ;
wns/raw Raw-.
" " WNS-. -
.NET, -
, WnsRecipe,
, .
.
-
.
.
, -
. ,
.
Windows Store--
, ,
( ""). -
WNS. WNS
, -
.
Taa12
""
, Windows 8 -
.
, (Tiles) . -
"" (Live Tile)
-
.
, (Secondary Tiles), -
, -
. , -
, , -
"" "", .
. ,
, , .
Windows 8 : 150150
(Square) 310150 (Wide) (. 12.1).
Windows Store-
(Package.appxmanifes) Tile
. ,
310150 . -
-
-
.
"" 163
. 12.1.
( -
, ), -
,
, , -
(. 12.2).
#464646.
. 12.2.
""
, Windows 8 "" ,
.
46 . -
MSDN. 10 36 .
, ,
. , -
( ). -
,
.
164 12
. 12.3.
. 12.4.
"" 165
. 12.3,
. 12.4.
. 12.1 12.2 -
.
, .
, , .
12.1.
(/)
12.2.
TileWideBlockAndText01 TileWideImage
TileWideBlockAndText02 TileWideImageCollection TileWideImageAndText01
TileWideText01 TileWideImageAndText02
TileWideText02 TileWideSmallImageAndText01
TileWideText03 TileWideSmallImageAndText02
TileWideText04 TileWideSmallImageAndText03
TileWideText05 TileWideSmallImageAndText04
TileWideText06 TileWideSmallImageAndText05
TileWideText07
TileWideText08 ()
TileWideText09 TileWidePeekImageCollection01
TileWideText10 TileWidePeekImageCollection02
TileWideText11 TileWidePeekImageCollection03
TileWidePeekImageCollection04
TileWidePeekImageCollection05
TileWidePeekImageCollection06
TileWidePeekImageAndText01
TileWidePeekImageAndText02
TileWidePeekImage01
TileWidePeekImage02
TileWidePeekImage03
TileWidePeekImage04
TileWidePeekImage05
TileWidePeekImage06
166 12
Windows Store- -
, . ,
, .
.
, -
, , -
.
XML-, -
, . ,
TileSquareBlock XML- 12.1.
<tile>
<visual>
<binding template="TileSquareBlock">
<text id="1">Text Field 1</text>
<text id="2">Text Field 2</text>
</binding>
</visual>
</tile>
TileSquareBlock -
. ( 12.2).
12.2.
<tile>
<visual>
<binding template="TileSquareBlock">
<text id="1">25</text>
<text id="2"></text>
</binding>
</visual>
</tile>
XML- () -
. XML-
TileNotification.
TileUpdater ( 12.3).
"" 167
12.3.
(. -
11) . , , -
, XML-.
-
. 12.5.
, -
( SmallLogo.png).
. 12.5.
168 12
XML- .
, - -
. XML-
TileUpdateManager. XML-
TileSquareBlock ( 12.4).
var xmlDocument =
TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareBlock);
: -
, -
.
MSDN NotificationsExtensions, -
. -
:
http://code.msdn.microsoft.com/windowsapps/app-tiles-and-badges-sample-
5fc49148
, -
XML-. NotificationsExtensions -
12.5.
12.5. NotificationsExtensions
XML- , . .
-
.
"" 169
.
.
.
, ,
. XML- (-
12.6). TileWideText03.
12.6. XML-
<tile>
<visual>
<binding template="TileSquareBlock">
<text id="1">10</text>
<text id="2"></text>
</binding>
<binding template="TileWideText03">
<text id="1">10 </text>
</binding>
</visual>
</tile>
,
12.3. -
. 12.6.
. 12.6.
170 12
"-
" . ,
. TileWideImage TileSquareImage
( 12.7).
12.7.
<tile>
<visual>
<binding template="TileSquareImage">
<image id="1" src="Assets\SmallLogo.png" alt="alt text"/>
</binding>
<binding template="TileWideImage">
<image id="1" src="Assets\WideLogo.png" alt="alt text"/>
</binding>
</visual>
</tile>
12.7
Windows Store-.
( 12.8).
12.8.
<tile>
<visual>
<binding template="TileSquareImage">
<image id="1" alt="alt text"
src="ms-appx:///Assets/SquareTileLogo.png" />
</binding>
<binding template="TileWideImage">
<image id="1" alt="alt text"
src="ms-appx:///Assets/WideLogo.png" />
</binding>
</visual>
</tile>
,
ms-appdata:///local/. ,
HTTP-, -
.
"" 171
, ,
. ,
.
, -
( 12.9).
12.9.
. -
"" 10 ( 12.10).
12.10.
, 12.10, ,
"" 10 . Windows 8 -
,
. , - ,
, , , -
, , . . .
, 10 ,
12.11.
12.11.
Windows 8 , ,
.
EnableNotificationQueue TileUpdater
( 12.2).
12.12.
,
(-
12.13).
12.13.
<binding template=""TileWideText03"">
<text id=""1"">{0} </text>
</binding>
</visual>
</tile>";
, -
. updateManager.Clear ,
,
.
,
,
.
( ). -
1
99 (, ), 100,
"99+" (, -
).
BadgeUpdateManager,
TileUpdateManager .
. , -
, XML-. 12.14 -
42 (. 12.7).
. 12.7.
174 12
12.14.
42 -
, "" .
, XML-
42 . , attention
( 12.15).
12.15.
xmlDocument.LoadXml(@"<badge value=""attention""/>"));
. 12.8.
. 12.8.
. 12.3.
12.3.
XML-
12.3 ()
XML-
. -
- "".
, . , -
. -
.
. -
, .
. -
:
Push-;
.
Push-, 11, , -
, . . -
. -
,
, Push-
, .
, , -
, . XML-
176 12
, -
-
. , , -
.
Push- .
, . . -
. Push- .
XML- , -
. ,
, , .
, XML- 12.6 :
http://foo.ru/TileHandler.ashx.
, (-
), -
( 12.16).
12.16.
updateManager.StartPeriodicUpdate(new Uri("http://foo.ru/TileHandler.ashx"),
PeriodicUpdateRecurrence.HalfHour);
, , ,
.
. -
( 12.17).
12.17. ,
updateManager.StartPeriodicUpdateBatch(uriCollection,
PeriodicUpdateRecurrence.HalfHour);
"" 177
. 12.18 -
XML- .
12.18.
updateManager.StartPeriodicUpdate(new
Uri("http://foo.ru/TileBadgeHandler.ashx"), PeriodicUpdateRecurrence.HalfHour);
(Secondary Tiles) Windows Store-
-
. ,
,
.
() . ,
, .
( 12.19).
12.19.
SecondaryTile, ,
.
()
(. 12.9), . -
.
178 12
. 12.9.
TileId , -
(, , . .).
App. -
-
.
,
. OnLaunched -
( App.xaml.cs) args -
TileId , .
, TileId,
12345, ( 12.20).
12.20. ,
if (rootFrame == null)
{
...
}
rootFrame.Navigate(typeof(SecondaryTilePage),
secondaryTileArgument);
}
else if (rootFrame.Content == null)
{
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
Window.Current.Activate();
}
!
,
, ,
.
12.20 :
, -
, -
.
, , "". -
TileUpdater,
CreateTileUpdaterForSecondaryTile TileUpdateManager TileId -
( 12.21).
12.21.
var updateManager =
TileUpdateManager.CreateTileUpdaterForSecondaryTile("TileId");
updateManager.Update(notification);
. -
Windows Store-, .
, , ,
, .
, -
.
, -
-
.
Taa13
""
Windows Store-
-
Windows 8 , -
.
"-". , , ,
. ,
- , .
-
.
. , ,
"San Francisco" Travel (),
. Maps (),
- , Weather ()
.
Windows Store-,
(Suggestions),
, ,
.
, Windows Store-
. , , -
"" ,
.
.
, , , -
(. 13.1).
"" 181
. 13.1.
, -
, .
. , -
(""), -
, .
"-".
-
. , -
.
.
,
.
Windows Store-. Windows- -
" ( ), ".
Windows XP Windows Vista Microsoft
, UAC (User Account Control -
).
, UAC .
182 13
, -
" , ". , -
, . -
UAC -
, .
, Windows Store-,
" , ".
, ,
.
Windows Store- -
.
""
""
. Blank App -
SearchApp.
"-" , -
, . ,
, .
.
( Package.appxmanifest)
Declarations. Available Declarations Search
Add (. 13.2).
, .
.
OnSearchActivated ( App.xaml.cs).
, .
SearchPage.xaml, Basic Page.
App.xaml.cs OnSearchActivated ( 13.1).
13.1. OnSearchActivated
if (rootFrame == null)
{
rootFrame = new Frame();
if (args.PreviousExecutionState ==
ApplicationExecutionState.Terminated)
{
...
}
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
Window.Current.Activate();
}
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}
rootFrame.Navigate(typeof(SearchPage), args.QueryText);
Window.Current.Activate();
}
}
184 13
. 13.2.
OnSearchActivated -
( <Enter>).
, SearchPage.xaml -
.
, , OnLaunched
. ,
OnSearchActivated OnLaunched.
, -
. , .
C#- SearchPage.xaml
, OnNavigatedTo. -
, -
( 13.2).
13.2. OnNavigatedTo
{
this.InitializeComponent();
}
base.OnNavigatedTo(e);
}
}
(. 13.3) ( -
).
. 13.3.
, -
.
. ,
, . -
OnSearchActivated,
186 13
. ,
.
,
, . .
OnLaunched ( -
). ,
.
-
. SearchPage.xaml
( 13.3).
13.3. SearchPage.xaml
<Page.BottomAppBar>
<AppBar>
<Button Style="{StaticResource HomeAppBarButtonStyle}"/>
</AppBar>
</Page.BottomAppBar>
HomeAppBarButtonStyle
StandardStyles.xaml. -
( 13.4).
13.4.
! .
-
Search Contract,
OnSearchActivated .
, .
, -
. ,
.
, .
-
.
"" 187
13.5.
base.OnNavigatedTo(e);
}
base.OnNavigatedFrom(e);
}
, SearchPage.xaml -
. MainPage.xaml,
SearchPage.xaml
(
).
? ,
(, -
188 13
), -
, -
.
,
, .
SuggestionsRequested SearchPane ( 13.6).
13.6.
base.OnNavigatedTo(e);
}
defferal.Complete();
}
, ,
(. 13.4).
!
SearchPage.xaml.
"" 189
. 13.4.
GetDefferral, deferral.Complete.
,
.
. , .
defferral, , - ,
deferral.Complete. -
.
,
, . -
,
,
.
. -
, . -
,
.
: App.xaml.cs -
Subscribe Unsubscribe ( 13.7) -
.
190 13
13.7.
defferal.Complete();
}
Subscribe OnLaunched
OnSearchActivated, Unsubscribe OnSuspending ( 13.8).
13.8.
, -
, , , .
. ,
.
,
, , , ,
. , -
SuggestionsRequested ( 13.9).
13.9.
args.Request.SearchSuggestionCollection.AppendResultSuggestion(
" ", "", "Id", image,
" ");
}
defferal.Complete();
}
. 13.5.
192 13
. 13.5.
, -
.
ResultSuggestionChosen SearchPane ( 13.10).
13.10.
Tag, -
. -
AppendResultSuggestion.
"" 193
.
. , -
.
-
. .
, , -
, .
Taa14
" "
. 14.1.
. 14.2.
196 14
( -
), Windows--
. , -
,
( , ,
).
.
Blank App ShareApp.
MainPage.xaml
txtMain, ( 14.1).
14.1. MainPage.xaml
<Page
...
>
DataTransferManager.
"-", -
, , -
DataRequested DataTransferManager.
MainPage,
( 14.2).
14.2. DataRequested
}
}
,
. ,
. ,
.
, .
, , SetText
DataPackage ( Data args.Request.Data) ( 14.3).
14.3.
defferal.Complete();
}
, .
. 14.3 ,
"" .
198 14
. 14.3.
(. 14.1).
14.1.
SetUri URI
SetRtf RTF
SetBitmap Bitmap
SetStorageItems StorageItems
SetData
SetDataProvider
. 14.1 - -
, . , -
.
Clipboard. 14.4.
" " 199
14.4.
Clipboard.SetContent(data);
, . 14.1.
, .
, ,
.
Package.appxmanifest Declarations.
Available Declarations Share Target -
Add.
, . -
, Text (. 14.4),
. .
,
OnShareTargetActivated ( App.xaml.cs) (-
14.5). Blank Page TargetPage.xaml,
.
14.5. OnShareTargetActivated
Window.Current.Content = frame;
Window.Current.Activate();
}
}
. 14.4.
OnShareTargetActivated -
TargetPage.xaml,
ShareOperation, .
, TargetPage.xaml
645 , "", -
.
" " 201
TargetPage.xaml ( 14.6).
14.6. TargetPage.xaml
<Page
...
>
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<TextBox x:Name="txtMain" AcceptsReturn="True"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
ScrollViewer.VerticalScrollBarVisibility="Visible"
FontSize="24" TextWrapping="Wrap"/>
</Grid>
</Page>
TargetPage.xaml
( 14.7).
14.7.
(
) , ,
.
202 14
- , -
"-". , ,
. . -
TargetPage.xaml (. 14.5).
. 14.5.
.
RandomAccessStreamReference. -
, , . -
( 14.8).
14.8.
args.Request.Data.Properties.Title = "";
args.Request.Data.Properties.Description = "";
" " 203
defferal.Complete();
}
, , -
( 14.9).
14.9. ,
Bitmap. , Image imgMain.
( 14.10).
14.10.
(Text, Bitmap, URI . .) -
. -
, - . , -
( , , ,
. .), Text, -
204 14
, . , ,
, ,
, .
SetData, ,
"Product". SetData
, XML, JSON (JavaScript Object
Notation). JSON, . . -
, JavaScript, C#, Visual Basic C++.
, -
( "Product"),
, JSON.
-
, ,
, -
, .
, -
- . , .
,
, http://schema.org.
, -
http://schema.org/Product, -,
Product, ,
-
!
( 14.11).
14.11.
var productFormat =
@"{
""type"" : ""http://schema.org/Product"",
""properties"" :
{
""name"" : ""{0}"",
""description"" : ""{1}"",
""productID"" : ""{2}""
}
}";
" " 205
dataPackage.SetData("http://schema.org/Product", productJson);
defferal.Complete();
}
-. , -
, http://
schema.org/Product.
JSON ( 14.12).
14.12. JSON
JSON JsonObject -
Windows.Data.Json.
, , -
.
, http://schema.org
JSON.
,
"" (, ) .
.
SetData. , - "" -
.
, - , -
"" . -
206 14
. ,
.
, ,
, . -
"" .
, ,
( 14.13).
14.13.
try
{
}
finally
{
defferal.Complete();
}
}
BinaryDataHandler .
( 1 10 000) (-
14.14).
14.14.
try
{
var stream = new InMemoryRandomAccessStream();
" " 207
await writer.StoreAsync();
await writer.FlushAsync();
writer.DetachStream();
}
stream.Seek(0);
request.SetData(stream);
}
finally
{
defferal.Complete();
}
}
,
InMemoryRandomAccessStream.
.
, -
(,
, "-
" . .), -
.
-
ReportStarted ShareOperation. -
ReportDataRetreived. -
- . -
, ReportCompleted ( 14.15).
-.
14.15.
//
shareOperation.ReportDataRetrieved();
//
shareOperation.ReportCompleted();
}
- , -
c ReportError ( 14.16).
14.16.
shareOperation.ReportError(" ");
,
, -,
( -).
.
, -
, .
, /. -
-
.
,
.
. -
.
Taa15
""
"-" (Settings).
.
Windows-
. Windows Store-
.
"-".
"-" ,
. , -
( ),
. Bing Weather -
. 15.1.
-
, .
.
Blank App SettingsApp.
, App.xaml.cs.
SettingsPane. -
CommandsRequested -
.
Subscribe Unsubscribe
, ( 15.1). -
-
.
210 15
. 15.1.
15.1. CommandsRequested
Window.Current.Activate();
}
currentPane.CommandsRequested += currentPane_CommandsRequested;
}
}
}
, -
Permissions (. 15.2).
.
SettingsCommand, args.Request.
ApplicationCommands ( 15.2).
15.2.
,
, .
. 15.3.
. 15.2. . 15.3.
, .
:
, , ,
.
"" 213
,
.
, .
-
.
Basic Page, .
SettingsFlyout.xaml.
XAML- . -
MSDN:
http://code.msdn.microsoft.com/windowsapps/App-settings-sample-1f762f49.
,
.
Popup, ( 15.3).
-
.
15.3.
_settingsPopup.Child = mypane;
_settingsPopup.SetValue(Canvas.LeftProperty,
SettingsPane.Edge == SettingsEdgeLocation.Right
? (Window.Current.Bounds.Width 646) : 0);
_settingsPopup.SetValue(Canvas.TopProperty, 0);
_settingsPopup.IsOpen = true;
});
applicationCommands.Add(newComand);
...
}
(. 15.4).
. 15.4.
"" 215
!
,
"" "".
.
,
"-". -
().
, , -
, .
. Popup
.
Taa16
Windows Store- ,
Windows-.
Windows Store-
, . . "" (Sandbox).
, , C:\ .
Windows Store-
, ( -
). -
,
(
17). -
, SQLite,
.
Windows Store- -
( , -
), . -
:
LocalFolder;
RoamingFolder;
TemporaryFolder.
.
:
LocalSettings;
RoamingSettings.
217
, -
. -
.
, LocalFolder, , -
. ,
, , SQLite , -
.
RoamingFolder -
, . -
, -
RoamingFolder . -
(RoamingSettings).
. ,
,
RoamingFolder , -
, .
(, -
). RoamingFolder
, , . .
100 .
, RoamingFolder -
!
, RoamingFolder, .
.
RoamingStorageQuota ( 16.1).
16.1.
ApplicationData.Current.RoamingStorageQuota
, RoamingFolder RoamingSettings
.
. , -
RoamingFolder , -
.
TemporaryFolder . ,
-
.
.
218 16
(string, bool, int,
float . .) ,
LocalSettings RoamingSettings. ,
RoamingSettings .
( ,
. .).
LocalSettings. -
( 16.2).
16.2. LocalSettings
ApplicationData.Current.LocalSettings.Values["MyKey"] = "";
, ( 16.3).
16.3. LocalSettings
,
NullReferenceException (bool, int, float
. .) ( 16.4).
16.4.
, RoamingSettings, -
. , -
1015 . -
, RoamingSettings
HighPriority, -
. 1530
( 16.5).
16.5.
ApplicationData.Current.RoamingSettings.Values["HighPriority"] = 42;
219
.
, (LocalFolder, RoamingFolder
TempraryFolder), .
, . -
( 16.6).
16.6.
16.6 -
.
FileIO. test.txt
"Hello World!" ( 16.7).
16.7.
16.8.
16.8.
RoamingFolder.
, , , ,
, .
DataChanged ( 16.9).
16.9.
, -
, . , -
, . , -
, -
.
( ) .
Windows 8 -
. , .
, -
. -
ApplicationData.Current.Version.
.
, 1.
SetVersionAsync (-
16.10).
16.10.
await ApplicationData.Current.SetVersionAsync(versionNumber,
UpgradeToVersionHandler);
versionNumber , UpgradeToVersion-
Handler ( 16.11).
16.11.
. , -
.
( ).
221
.
, , XAML-. Windows 8
:
ms-appx:/// , ;
ms-appdata:///local/ LocalFolder;
ms-appdata:///roaming/ RoamingFolder;
ms-appdata:///temp/ TemporaryFolder.
16.12 .
16.12.
Path
. ,
ApplicationData.Current.LocalFolder.Path:
C:\Users\<UserName>\AppData\Local\Packages\f7cb881e-53dd-47d9-b559-
57defb00a8fb_1ajdc8xvgt2ym\LocalState\
<UserName> , , f7cb881e-
53dd-47d9-b559-57defb00a8fb_1ajdc8xvgt2ym .
Windows Explorer,
.
SQLite
, -
, .
(). Windows 8
(). -
,
. SQLite, , -
.
SQL.
222 16
. , SQLite
Windows Store-.
SQLite -
. Tools | Extensions and Updates -
SQLite for Windows Runtime (. 16.1).
Visual Studio. -
SQLite Windows Store-.
Blank App SqliteApp.
References ( Solution
Explorer) Add Reference... -
SQLite for Windows Runtime Microsoft Visual C++ Runtime Package
(. 16.2).
!
Microsoft Visual C++ Runtime Package.
, , -
Windows Store.
. 16.2. SQLite
. 16.3.
224 16
.NET- -
ORM (Object-Relational Mapping), -
LINQ (Language Integrated Quiries). SQLite -
. sqlite-net.
Solution Explorer Manage
NuGet Packages..., sqlite-net (. 16.4).
. 16.4. sqlite-net
, .
16.13.
, .
16.13.
SQLite . -
- , Microsoft SQL Server Oracle Database.
Windows Store-.
sqlite-net LINQ-,
ADO.NET. .
225
, . ,
, . -
,
250 (-
16.14).
16.14.
.
Product ( 16.15).
16.15.
-
data.db. SQLite, -
, SQLite. -
, SQLite, SQLite Expert
Personal:
http://www.sqliteexpert.com/download.html.
SQLite Expert Personal
Product (. 16.5).
.
Product ( 16.16).
226 16
16.16.
db.Insert(product);
}
, 16.16, ProductId
Product .
( 16.17).
16.17.
, SQL-. , -
2 ( 16.18).
227
16.18. SQL-
( 16.19).
16.19.
LINQ, (, -
) -
SQL-.
SQL-, ( 16.20).
16.20. SQL-
. 16.21 , -
Product.
16.21. ,
Windows 8 Windows .
Windows 8
. -
, ,
.
Windows Store- -
: LocalFolder, RoamingFolder TemporaryFolder,
, .
.
, , -
. -
SQLite.
Taa17
, , Windows Store-
.
. -
, -
, 16.
, .
, .
- ,
"", ,
.
.
FileOpenPicker
FileOpenPicker , , -
, OpenFileDialog Windows Forms. FileOpenPicker
. ,
.
FileOpenPicker 17.1.
17.1. FileOpenPicker
FileOpenPicker -
, . (-
230 17
, ,
), "*".
, ,
".jpg".
( 17.2).
17.2. FileOpenPicker
if(file!=null)
{
...
}
, . -
NULL.
PickMultipleFilesAsync (-
17.3).
17.3.
FileOpenPicker ,
. , , , ,
FileOpenPicker "" (-
17.4).
17.4.
openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
, , "",
"" . .:
DocumentsLibrary;
ComputerFolder;
231
Desktop;
Downloads;
HomeGroup;
MusicLibrary;
PicturesLibrary;
VideosLibrary.
, , :
( ) ( 17.5).
17.5.
openPicker.ViewMode = PickerViewMode.Thumbnail;
. ,
, ""
( 17.6).
17.6.
openPicker.CommitButtonText = "";
, FileOpenPicker ,
17.7.
17.7. FileOpenPicker
if (file != null)
{
//
}
. 17.1.
232 17
. 17.1.
!
, ,
, SkyDrive. ,
, -
.
FileSavePicker
FileSavePicker, -
SaveFileDialog Windows Forms. FileSavePicker -
.
17.8.
17.8.
, ,
NULL, -
NullReferenceException.
.
, ( SkyDrive).
,
CachedFileManager.
FolderPicker
, -
, . -
.
-
FolderPicker, FolderBrowserDialog
Windows Forms ( 17.9).
17.9. FolderPicker
, -
,
(. 17.2). ,
,
"" .
, .
, :
Documents Library;
Music Library;
234 17
Pictures Library;
Videos Library;
Removable Storage.
. 17.2.
Documents Library ,
.
Documents Library.
File
Type Associations.
KnownFolders ( 17.10).
, :
KnownFolders.HomeGroup;
KnownFolders.MediaServerDevices.
235
( ).
. ,
Supports any file type.
236 17
, -
. ,
FileOpenPage.xaml ( 17.11).
<Page
...
>
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center">
<TextBlock Text=" FileOpenPage.xaml" FontSize="72" />
<Button Content=" " HorizontalAlignment="Center"/>
</StackPanel>
</Grid>
</Page>
App.xaml.cs
OnFileOpenPickerActivated,
( 17.12).
. -
, () args.
FileOpenPage.xaml
( 17.13). Logo.png -
.
17.13.
if (_args != null)
{
var result = _args.FileOpenPickerUI.AddFile("fileId", file);
}
}
}
17.13 ,
, . ,
IStorageFile, -
, ,
.
, FileOpenPicker,
(. 17.4).
(. 17.5).
238 17
. 17.4.
. 17.5. FileOpenPage.xaml
239
File Save
Picker.
StorageApplicationPermissions
. -
, ,
. ,
, , -
.
Windows 8
.
, , , FileOpenPicker,
-
( 17.14).
17.14.
FutureAccessList.Add,
, -
.
( 17.15).
17.15.
{
var file = await accessList.GetFileAsync(fileToken);
}
FutureAccessList.Entries.
,
, -
( 17.16).
17.16.
. , -
, ,
.
File Type Associations.
,
txt, png . . qwerty
(. 17.6).
,
.
( Icon.png).
App.xaml.cs
OnFileActivated ( 17.17).
17.17.
frame.Navigate(typeof(MainPage), args.Files);
Window.Current.Activate();
}
}
. 17.6.
() MainPage.xaml. -
MainPage.xaml , .
( 17.18).
17.18.
{
this.InitializeComponent();
}
...
}
, qwerty
(. 17.7). .
qwerty .
.
, . -
, FTP- ftp,
http https. -
qwerty.
Protocol (. 17.8).
OnActivated App.xaml.cs ( 17.19).
17.19.
. 17.7.
. 17.8.
244 17
Window.Current.Activate();
}
}
MainPage.xaml
, .
FileOpenPicker
FileSavePicker, FolderPicker.
StorageApplicationPermissions,
.
,
"", .
.
File Open Picker File Save Picker
, -
.
, , txt -
, , ftp.
Taa18
(Web-
) . -
, -
. ,
,
, .
, .
Windows 8 .
,
, .
, . -
.
,
. Blank App
Camera App.
,
Webcam. ,
Microphone (. 18.1).
CameraCaptureUI
-
/ CameraCaptureUI. , -
( ), . -
CameraCaptureUI , -
. , ,
.
246 18
. 18.1.
MainPage.xaml ,
Image. XAML-
MainPage 18.1.
18.1. MainPage
<Page
...
>
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<Button Content=" "/>
<Image x:Name="imgMain" Width="640" Height="480"/>
</Grid>
</Page>
. -
CameraCaptureUI ( 18.2).
247
18.2.
if (file != null)
{
BitmapImage bitmapImage = new BitmapImage();
using (IRandomAccessStream fileStream = await
file.OpenAsync(FileAccessMode.Read))
{
bitmapImage.SetSource(fileStream);
}
imgMain.Source = bitmapImage;
}
}
18.2
, , -
, Image .
!
NULL. -
( "").
NULL. -
NULL, -
.
. -
,
, (. 18.2).
, , -
, -
, ,
.
CameraCaptureUIMode.Photo CameraCaptureUIMode.Video,
, .
. -
MediaElement ( 18.3).
248 18
. 18.2.
18.3. MediaElement
( 18.4).
18.4.
if (file != null)
{
IRandomAccessStream fileStream = await
file.OpenAsync(FileAccessMode.Read);
meMain.SetSource(fileStream, "video/mp4");
}
}
249
CameraCaptureUIMode.Video,
CameraCaptureUIMode.PhotoOrVideo. -
.
CameraCaptureUI PhotoSettings VideoSettings, -
. -
.
PhotoSettings.AllowCropping
AllowCropping ( true) ,
( 18.5). , -
.
18.5. AllowCropping
PhotoSettings.CroppedAspectRatio
CroppedAspectRatio -
. , , , -
.
18.6 , 2 1
.
18.6.
, -
. ,
AllowCropping false. , -
CroppedAspectRatio CroppedSizeInPixels.
PhotoSettings.CroppedSizeInPixels
, ,
, CroppedSizeInPixels,
250 18
, (-
18.7).
18.7.
, . -,
. ,
, ,
, . -
, , -
, , -
.
PhotoSettings.Format
Format CameraCaptureUIPhotoFormat -
. : JPEG, PNG JPEG XR.
JPEG XR , Windows
Media Photo. , JPEG. JPEG
XR .
JPEG XR 18.8.
18.8.
JPEG XR , . .
. , -
JPEG ( ) PNG.
PhotoSettings.MaxResolution
, ,
. MaxResolution
CameraCaptureUIMaxPhotoResolution :
HighestAvailable ( -
);
VerySmallQvga ( 320240);
SmallVga ( 320240);
251
MediumXga ( 1024768);
Large3M ( 19201080);
VeryLarge5M ( 5 ).
( 18.9).
18.9.
VideoSettings.AllowTrimming
, "" -
. AllowTrimming
( 18.10).
18.10. AllowTrimming
VideoSettings.Format
Format , ,
( 18.11).
MP4 ( ) WMV.
18.11.
VideoSettings.MaxDurationInSeconds
MaxDurationInSeconds -
( 18.12).
. -
AllowTrimming false. , -
- ,
,
, .
252 18
18.12.
VideoSettings.MaxResolution
, -
( 18.13). MaxResolution
:
HighestAvailable ;
LowDefinition ;
StandardDefinition ;
HighDefinition .
, -
. ,
MaxResolution.
18.13.
MediaCapture
/
/ . ,
,
,
. MediaCapture, c -
,
.
.
MediaCapture ( 18.14). -
-
.
18.14. MediaCapture
{
if (_mediaCapture == null)
{
_mediaCapture = new MediaCapture();
try
{
await _mediaCapture.InitializeAsync();
_mediaCapture.RecordLimitationExceeded += async (sender) =>
{
//
await _mediaCapture.StopRecordAsync();
};
}
catch (UnauthorizedAccessException)
{
//
}
}
}
, -
StartRecordToStorageFileAsync,
, IStorageFile.
(
CameraCaptureUI,
). StartRecordToStreamAsync
.
, -
.
MainPage.xaml.
, , . -
( 18.15).
18.15.
await _mediaCapture.StartRecordToStreamAsync(encodingProfile,
_stream);
}
catch (Exception ex)
{
//
}
}
//
private async void Stop_Button_Click(object sender, RoutedEventArgs e)
{
await _mediaCapture.StopRecordAsync();
}
//
private void Play_Button_Click(object sender, RoutedEventArgs e)
{
meMain.SetSource(_stream, "audio/mp3");
meMain.Play();
}
, , .
, MP3 -
MediaEncodingProfile.CreateMp3.
MediaElement,
CameraCaptureUI .
.
CaptureElement,
( 18.16).
18.16. CaptureElement
MediaCapture
CaptureElement StartPreviewAsync
( 18.17).
18.17.
ceMain.Source = _mediaCapture;
await _mediaCapture.StartPreviewAsync();
"" , -
MainPage.xaml (. 18.3).
255
. 18.3. ""
,
"" ( 18.18). -
. ,
() "", 17.
18.18.
var encodingProfile =
MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);
await _mediaCapture.StartRecordToStorageFileAsync(
encodingProfile, _recordVideoFile);
}
256 18
MediaCapture
CapturePhotoToStorageFileAsync CapturePhotoToStreamAsync. ,
, ,
- .
MediaCapture
,
. CameraCaptureUI -
. , -
?
DeviceInformation.
, -
( 18.19).
18.19.
await _mediaCapture.InitializeAsync(settings);
}
MediaCapture
VideoDeviceController.
257
:
BacklightCompensation ;
Brightness ;
Contrast ;
Exposure ;
Focus ;
Hue ;
Pan ;
Roll ;
Tilt ;
WhiteBalance ;
Zoom .
,
CameraOptionsUI ( 18.20).
18.20.
CameraOptionsUI.Show(_mediaCapture);
(. 18.4)
, , -
.
AudioDeviceController
:
Muted ( -
true false);
VolumePercent (-
0 100).
. 18.4. CameraOptionsUI
258 18
Windows Store-.
/ .
CameraCaptureUI.
, ( , ),
.
.
"" ,
. ,
CameraCaptureUI, .
-
, , , -
.
.
Taa19
,
. , Bing Maps Microsoft, -
, , ,
. .
,
,
. , ,
, , -
, ,
. , ,
, . , -
-
, . ,
, , -
. - -
, , -
, .
-
, Bing Maps SDK,
Microsoft.
Windows 8, Bing Maps SDK . -
, -
SDK Windows 8, Bing.
,
, -
. GPS (Global Position System), -
260 19
, -
Wi-Fi, IP-. -
. , , -
, IP-
50 , , Wi-Fi,
350 , / GPS 10 .
, -
-
, .
. ,
.
.
,
, , GPS (
IP-) .
. -
( ) (
Active Directory) ,
.
, -
, -
. ,
. , -
,
. ,
Airplane Mode, -
.
-
. Blank App
LocationApp.
Package.appxmanifest Capabilities
Location (. 19.1).
MainPage.xaml -
( 19.1).
,
txtLatitide, txtLongitude txtAccuracy .
261
. 19.1.
<Page
...
>
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button x:Name="btnLocation"
Content=" " Grid.Row="0"
VerticalAlignment="Center" HorizontalAlignment="Center"
Margin="10" />
<StackPanel Grid.Row="1"
Orientation="Vertical" VerticalAlignment="Top"
HorizontalAlignment="Center">
<TextBlock x:Name="txtAccuracy" Style="{StaticResource
HeaderTextStyle}" Margin="5"/>
262 19
</Grid>
</Page>
API , -
, -
( ).
btnLocation.
.
Geolocator Windows.Devices.Geolocation. -
GetGeopositionAsync ( 19.2).
19.2.
try
{
var position = await geolocator.GetGeopositionAsync();
GetGeopositionAsync Geoposition,
Coordinate Geooordinate. Geooordinate -
(. 19.1).
263
19.1. Geooordinate
Accuracy
Latitude
Longitude
Speed
Altitude
AltitudeAccuracy
Heading
Timestamp ,
, (,
IP-), null.
. btnLocation
, -
(. 19.2). ,
(. 19.3).
. 19.2.
. 19.3.
, -
, DesiredAccuracy
Geolocator ( 19.3).
.
264 19
19.3.
-
, , ,
. -
.
( ). -
. -
LocationStatus
Geolocator. -
StatusChanged.
, -
, Disabled.
.
Geolocator
. ,
Geolocator .
,
-
. btnLocation.
, -
.
- , , , . .
.
, Geolocator
PositionChanged ( 19.4).
19.4.
public MainPage()
{
InitializeComponent();
}
265
,
, -
( ) -
Dispatcher.RunAsync.
PositionChanged? -
, -
. -
MovementThreshold ( ) Geolocator. -
19.5 , .
19.5.
, PositionChanged -
, -
MovementThreshold, ,
, - .
266 19
MovementThreshold . -
.
, ,
PositionChanged.
ReportInterval,
, -
.
, . 19.6
ReportInterval .
19.6.
ReportInterval , -
, -
.
ReportInterval,
. , -
.
ReportInterval.
:
, .
, -
. -
(. 19.4).
, , ,
(. 19.5). Set
Location.
, .
, ,
, , , -
. -
,
.
10.
267
. 19.4. . 19.5.
. 19.8.
Windows Store
(x86, x64, ARM), -
, Bing Maps SDK.
,
Map.
, , -
( 19.7).
<Page
x:Class="LocationApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:LocationApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup- compatibility/2006"
xmlns:bing="using:Bing.Maps"
mc:Ignorable="d">
270 19
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button x:Name="btnLocation"
Content=" " Grid.Row="0"
VerticalAlignment="Center" HorizontalAlignment="Center"
Margin="10" Click="BtnLocationClick"/>
!
XML bing:
xmlns:bing="using:Bing.Maps", Map: <bing:Map
Grid.Row="1" x:Name="map"/>.
,
(. 19.9).
, ,
. Map
. 19.9. Map
271
Bing,
.
Bing Maps: http://www.bingmapsportal.com/.
,
Credentials Map.
, ( 19.8).
, 19.8, . .
: /
( ZoomIn ZoomOut), "/
" (LayoutChange) ( 19.9).
19.9.
<Page
...
>
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal"
HorizontalAlignment="Center">
<Button x:Name="btnLocation"
Content=" " Grid.Row="0"
VerticalAlignment="Center" HorizontalAlignment="Center"
Margin="10" Click="BtnLocationClick"/>
19.10.
19.10.
.
GeolocatorPositionChanged -
SetView ( 19.11).
19.11.
map.SetView(location, 10);
});
}
SetView . -
, .
,
.
,
, .
MainPage Pushpin ( 19.12).
19.12. Pushpin
Pushpin -
,
( 19.13).
19.13. Pushpin
map.SetView(location, 10);
MapLayer.SetPosition(_pushpin, location);
if (!map.Children.Contains(_pushpin))
{
map.Children.Add(_pushpin);
}
});
}
Pushpin
SetPosition MapLayer.
. -
(. 19.10).
274 19
. 19.10. Pushpin
, -
, .
Geolocator.
, .
Bing Maps SDK, -
Bing. , Map,
, .
Taa20
, Windows 8,
,
" ", . . , -
, -
, , -
, ,
.
, ,
: ( -
19), ,
. , -,
,
, .
, , -
, , . -
. , / -
, , -
. API , ,
, .
. -
, .
,
.
-
. , , ,
,
276 20
(. 20.1). , -
, .
,
.
. 20.1.
<Page
...
>
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}"
x:Name="LayoutRoot">
Grid LayoutRoot,
txtLight.
, , -
, - -
.
LightSensor
Windows.Devices.Sensors. -
277
, LightSensor.GetDefault(). -
null, .
, , ,
. (-
20.2).
20.2.
,
, . -
ReadingChanged LightSensor. C#- -
MainPage 20.3.
20.3.
public MainPage()
{
this.InitializeComponent();
_lightSensor = LightSensor.GetDefault();
if (_lightSensor != null)
{
_lightSensor.ReadingChanged += LightSensorReadingChanged;
}
}
}
}
, -
( 20.4).
278 20
20.4.
Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
LayoutRoot.Background = new SolidColorBrush(Color.FromArgb(255,
(byte)(reading.IlluminanceInLux / 2), 0, 0));
txtLight.Text = reading.IlluminanceInLux.ToString();
});
}
,
ReportInterval. -
( 20.5).
20.5.
_lightSensor.ReportInterval = _lightSensor.MinimumReportInterval;
(Resource leak),
, , -
( 20.6).
20.6.
base.OnNavigatedFrom(e);
}
-
(g ), -
(. 20.2).
279
. 20.2.
. ,
Z- 1 ( Z , -
, , 1g). ,
, Y- 1.
, .
, , -
1g.
Accelerometer, -
Windows.Devices.Sensors. -
, , ,
GetDefault().
AccelerometerReading,
AccelerationX, AccelerationY AccelerationZ, -
.
, -
, 20.7.
20.7.
public MainPage()
{
this.InitializeComponent();
_accelerometer = Accelerometer.GetDefault();
if (_accelerometer != null)
280 20
{
_accelerometer.ReadingChanged += AccelerometerReadingChanged;
}
}
var x = reading.AccelerationX;
var y = reading.AccelerationY;
var z = reading.AccelerationZ;
});
}
}
"" . ,
, (. 20.3).
. 20.3.
, ,
( ).
, . -
, .
. . 20.4 -
, , . -
, .
, -
, , . -
281
,
( 20.8). -
Shaken.
. 20.4. , ,
20.8.
public MainPage()
{
this.InitializeComponent();
_accelerometer = Accelerometer.GetDefault();
if (_accelerometer != null)
{
_accelerometer.ReadingChanged += AccelerometerReadingChanged;
_accelerometer.Shaken += AccelerometerShaken;
}
}
.
. , , ,
. -
, , -
, .
282 20
. -
. -
Gyrometer ( 20.9).
20.9.
public MainPage()
{
this.InitializeComponent();
_gyrometer = Gyrometer.GetDefault();
if (_gyrometer != null)
{
_gyrometer.ReadingChanged += GyrometerReadingChanged;
}
}
//
var x = reading.AngularVelocityX;
var y = reading.AngularVelocityY;
var z = reading.AngularVelocityZ;
});
}
}
( . incline ) ,
.
Windows 8, . .
.
, ( -
283
)
Sensor Fusion (. 20.5).
, .
. -
, .
.
: Roll (), Pitch () Yaw
(),
(. 20.6).
, ( -
).
. 20.7 Roll, Pitch Yaw .
, . Z (Yaw)
, .
X (Pitch) , , . -
Y (Roll) .
.
( -
,
). - -
. -
DirectX,
.
. -
,
.
. .
Blank App InclinometerApp.
XAML- MainPage 20.10.
<Page
...
>
<Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
285
<Canvas VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Rectangle x:Name="rectMain" Fill="Red" Width="100"
Height="100" Canvas.Left="500" Canvas.Top="300"/>
</Canvas>
</Grid>
</Page>
StackPanel , -
Roll, Pitch Yaw . -
Canvas rectMain, .
C#- .
"" Inclinometer.
( 20.11).
20.11.
public MainPage()
{
this.InitializeComponent();
_inclinometer = Inclinometer.GetDefault();
if (_inclinometer != null)
{
uint reportInterval = _inclinometer.MinimumReportInterval >
16 ? _inclinometer.MinimumReportInterval : 16;
if (reading != null)
{
//
var top = (double)rectMain.GetValue(Canvas.TopProperty);
var left = (double)rectMain.GetValue(Canvas.LeftProperty);
rectMain.SetValue(Canvas.TopProperty,
top (reading.PitchDegrees / (double)4));
rectMain.SetValue(Canvas.LeftProperty,
left (reading.RollDegrees / (double)4));
//
txtRoll.Text = String.Format("Roll: {0,5:0.00}",
reading.RollDegrees);
txtPitch.Text = String.Format("Pitch: {0,5:0.00}",
reading.PitchDegrees);
txtYaw.Text = String.Format("Yaw: {0,5:0.00}",
reading.YawDegrees);
}
}
}
. , -
ReadingChanged .
.
.
, . -
, .
Sensor Fusion.
,
. Compass.
. ,
, -
, , .
287
,
,
. , .
( ), VSM (Visual
State Manager), ApplicationView.Value (-
, ). -
9. -
.
SimpleOrientationSensor.
20.12.
20.12.
if(orientation!=null)
{
var currentOrientation = orientation.GetCurrentOrientation();
}
OrientationChanged
SimpleOrientationSensor.
, , . 20.1.
20.1. ,
NotRotated
Rotated90DegreesCounterclockwise 90
Rotated180DegreesCounterclockwise 180
Rotated270DegreesCounterclockwise 270
Faceup
Facedown
, -
View ApplicationView: FullScreenLandscape,
FullScreenPortrait, Filled Snapped.
288 20
, , "" .
,
OrientationSensor.
.
, .
.
. -
GetDefault -
. null.
null .
-
. .
, , ,
, , -
Sensor Fusion .
, -
.
Taa21
,
. , , -
, .
,
, . -
- .
,
. , , ,
, . -
, , -
.
. .
, . . -
, , ,
.
, , , ,
, -
, .
(Internationalization, i18n), -
. ,
.
.
, -
.
290 21
, -
, . -
, . -
, -
.
,
, . ,
-
, .
Windows Store- .NET- Windows Phone-
. , Windows 8, ,
, . -
, .
21.1.
21.2.
, (-
21.3).
21.3.
( Package.appxmanifest).
Default language (. 21.1).
, , -
. ,
"ru-RU". , , -
"en", .
( ) -
PrimaryLanguageOverride ApplicationLanguages
( 21.4).
21.4.
ApplicationLanguages.PrimaryLanguageOverride = "de-DE";
Windows 8 Windows
, ( -
292 21
. 21.1.
) . Windows 8 ,
. , -
, , -
. , , ( )
.
(Control Panel) Control
Panel | Language (. 21.2).
. 21.2.
, . Windows Store-
GlobalizationPreferences.Languages.
( -
. " " ), -
293
, , , -
.
-
, , -
( ), -
.
, -
, , .
Windows Store- ( , WPF, Silverlight
Windows Phone-) XAML-
. XAML-, , -
, . Windows 8
,
XAML.
, "Hello!" "World!"
( 21.5).
, , .
21.5.
<StackPanel>
<TextBlock Text="Hello!" Width="400"
HorizontalAlignment="Left" Margin="10"
Style="{StaticResource HeaderTextStyle}" />
<TextBlock Text="World!" Width="400"
HorizontalAlignment="Left" Margin="10"
Style="{StaticResource HeaderTextStyle}" />
</StackPanel>
: Width,
HorizontalAlignment Margin. -
(x:Uid) .
Hello World ( 21.6).
21.6.
<StackPanel>
<TextBlock x:Uid="Hello" Text="Hello!" Width="400"
HorizontalAlignment="Left" Margin="10"
Style="{StaticResource HeaderTextStyle}" />
294 21
,
. Languages ( -
) : en-US ru-RU. -
Resources.resw, Resource File (.resw)
(. 21.3).
. 21.3.
resw .NET-
resx: , resw- -
. en-US
, . 21.1 (. 21.4).
21.1. en-US
Hello.HorizontalAlignment Left
Hello.Text Hello!
Hello.Width 400
World.Text World!
295
. 21.4. en-US
ru-RU . 21.2.
21.2. ru-RU
Hello.HorizontalAlignment Right
Hello.Text !
Hello.Width 500
World.Text !
. -
. ,
.
, "!", -
, "!". "Hello!",
, "World!".
Windows 8 -
( ).
, , .NET
Framework, .
Windows 8 .lang-.
, ru-RU -
: Resources.lang-ru-RU.resw.
296 21
-
:
Resources.lang-de-DE.resw;
Resources.lang-de-AT.resw;
Resources.lang-de-CH.resw.
, ,
: Resources.resw.
, , , -
, Languages,
, Localization. .
. , "en",
"ru", "de". -
, -
, . -
"en-US" .lang-en-US .
"de-DE" .lang-de-DE.
, ,
, ? -
,
.
:
Languages\de\Resources.lang-de-DE.resw;
Languages\de\Resources.lang-de-AT.resw;
Languages\de\Resources.lang-de-CH.resw.
:
Languages\de-DE\Resources.resw;
Languages\de-AT\Resources.resw;
Languages\de-CH\Resources.resw.
, , .
, ,
Images\logo.png, ,
:
Images\en\logo.png;
Images\ru\logo.png
( 21.7).
297
21.7. XAML-
9, -
, . -
-
:
Images\ru\logo.scale-100.png;
Images\ru\logo.scale-140.png;
Images\ru\logo.scale-180.png.
(contrast-white
contrast-black).
( High
Contrast PC settings | Ease of Access):
Images\ru\contrast-black\logo.scale-100.png;
Images\ru\logo.contrast-black_scale-100.png.
. , -
ErrorMessage,
( 21.8).
21.8.
.
-
Resources.resw. , -
Errors.resw.
Errors.resw, ResourceLoader -
( 21.9).
21.9. Errors.resw
, -
, . ,
Errors.resw LocalizationLibrary.dll, -
( 21.10).
21.10.
Windows Store- .
(
):
ApplicationDisplayName;
ApplicationShortName;
ApplicationDescription.
, -
.
ms-resource:, , ms-resource:ApplicationDisplayName (. 21.5).
. 21.5.
299
, , -
, .
Windows Store-
. , , -
,
,
.
Windows Store-
, . .
. ,
. , -
, Windows 8, -
.
Taa22
Windows 8
Windows 8, Microsoft (,
Windows Phone, Xbox 360 Visual Studio 2012),
, -
. , -
.
-
, - -
. ,
, , -
, , ,
.
, ,
, , ,
.
Windows 8
, , ,
Windows Phone Windows 8,
"Metro"-. "Metro" -
, -
Windows Phone Windows 8.
, ,
(, , -
, "Avalon", Windows
Presentation Foundation, WPF), "Metro" -
, "Windows". -
Windows 8 301
Windows,
Windows, Windows 8.
, , ,
, , -
, , -
,
.
Microsoft , -
, Windows Media Center (. 22.1).
Microsoft Zune
( ), (Zune Windows
Zune.net ) (. 22.2 22.3).
, Windows
Zune.net Silverlight Cosmopolitan.
, Windows Phone 7,
-
.
Microsoft, -
. ,
.
, ,
, . ,
302 22
. 22.2. Zune HD
Windows, ,
Microsoft.
(Bauhaus) (, ,
), , -
,
.
(International Typographic Style,
Swiss Design) , -
, ( , -
) (
). ,
.
(Motion Design) -
( ), , -
, -
""
.
, , , , -
, ,
, -
, , Windows 8 Windows
Phone.
Windows
:
1. .
2. .
3. - .
4. .
5. .
.
, . ,
, ,
, , , -
, .
, - ,
, , -
.
304 22
, , , -
, - -
.
. . , -
, , , -
- , -
.
, (
).
,
(Information Architecture, IA). , -
, ,
, ,
, .
,
, , , .
,
: ,
.
, -
.
,
, .
( Windows 8
2020 px 55 px) (. 22.4).
. 22.4.
, -
,
.
Windows 8 305
,
-
, ( -
, ).
, , ,
. -
, , ,
,
(. 22.5).
. 22.5.
, , Visual Studio, -
: 42 pt, 20 pt, -
11 pt, 9 pt.
, , .
. ,
. ,
.
, , -
, , , -
, ,
"". , ,
"" - Windows 8
. ( , "" Mac OS X,
306 22
, -
, .)
"" . . (
?) , ,
, iOS, . -
, , , , -
. ,
( ),
/ Windows
.
(
) ,
, .
, Windows ( Windows
Phone) , -
. .
Windows 8 Cocktail Flow (. 22.6).
, , -
.
,
, ,
.
Windows 8 307
"" -
. . -
. , -
. .
, , , -
.
Windows 8, -
, , ,
. , -
, ,
, .
, ( -
),
.
. (, , ),
, , -
, (, ) -
.
!
" " ,
.
(Chrome).
, , ,
(, ,
, ). -
, -
.
:
;
;
.
.
. ,
, -
. "".
, (. 22.7).
308 22
, , (
), , , ,
( , ).
. -
: ,
, , -
. , -
() .
,
,
" ", "" -
. .
,
.
.
, " " (. 22.8).
, , - -
: , ,
, (
)
.
- , -
. Windows 8
.
Windows 8 309
. 22.8. ""
.
- , -
. . , , ,
,
.
,
. - , -
, , -
(),
, , " ".
, - ( -
). Windows 8 ?
-, , -
"-", -
, ,
. -
-
.
-, ,
(, ,
), , -
, , -
(. 22.9).
310 22
, -
,
, .
, .
, -
, , , -
, , .
23. ,
,
. , , ,
.
, .
, -
. (, ), -
, , .
.
.
Windows
. ,
, .
. , " -
Windows 8 311
", , , ,
.
. .
-
, -
,
, .
, -
, "".
, -
.
. , , , -
(. 22.10).
. 22.10. ""
, ,
-
, , , . ,
( ).
, ,
Segoe UI,
312 22
Windows 8.
, ,
.
, , -
. , , ,
"" , ,
, , -
.
; , -
, , -
.
. -
, , -
,
.
, ,
, -
. , , -
, -
.
,
,
, , ,
, ().
, Win-
dows 8.
,
(Semantic Zoom), 8.
, , ,
"" ,
, , , , -
(. 22.11 22.12).
"", -
(/). ,
-
, -
. , , -
, ,
, , -
(, , . .),
, , .
Windows 8 313
"". -
( ). ,
Web-,
.
, "" -
.
, .
-
.
314 22
, - -
. -
(, ),
, , , , -
, ,
.
, -
"".
: -
, - ,
, "".
,
. ,
"" ,
, , ,
. , -
.
, ,
. -
, -
, , -
.
,
, ,
, , .
, "" , , .
. , -
.
,
. , ,
,
, .
, ( ) -
, ,
, , - .
, "", -
, -
.
Windows 8 315
Windows 8,
, , , . -
.
, -
. -
, , - (. 22.13).
. 22.13. Windows 8
, , Windows 8
" ", ,
, , (
7 ),
, -
.
. -
.
Windows 8 (
, ).
, -
, , -
, , ,
"-" ( -
), , ,
.
-
, , Windows 8
316 22
(Animation Library)
Windows.UI.Xaml.Media.Animation XAML/C#
WinJS.UI.Animation HTML/JS.
"". , - "", -
. , "" -
, ,
.
10, Windows Store-,
, , -
.
, , , - .
, " -
" , .
( ).
. , -
, , ,
"". , -
, ,
, -
. "" -
.
, . . -
, , , -
. ,
,
.
"".
, , -
, -
, .
, . ,
,
, , ,
, .
"" , -
.
, , , -
, , . ,
, , .
Windows 8 317
, Windows Store, -
, .
. , , . -
,
-.
,
, , -
/ .
, :
,
, , , , ,
.
, -
( , ).
Windows-
, -
.
, , : Windows 8
Windows RT. , Windows Store, -
, , ARM-
Intel/AMD- .
, -
GPU (" "), CPU (), , -
, .
,
, -
. , -
, . ,
.
, ,
.
.
. Windows 8 "",
.
,
.
. 1315 .
-
,
.
318 22
(Sharing) (, -
. .).
, Windows 8
"-" " ".
, : , -
, , .
, .
, -
,
.
, , ,
. , -
, ,
.
(Mail),
, "",
(People), -
. .
-
.
, -
, , , , , . -
,
, .
.
.
. , " ", -
. ( Visual Studio,
Adobe Photoshop), (
http://design.windows.com) Expression Blend (
XAML HTML) -
.
,
Windows:
1. .
, . "".
2. . ,
, .
Windows 8 319
3. - .
, , -
.
4. . -
, , .
5. . Windows Windows -
, , -
.
Taa23
,
Windows 8
, , ,
, Windows 8 Windows
Phone, -
(UX UI).
( ) -
Windows 8 -
, Web-. "-
" ,
,
.
, Windows 8 (
, C#, Visual Basic, JavaScript C++), -
, ( ) , . , ,
Windows 8 , -
.
, , -
, -
, -
( )
.
,
. , -
, . : -
.
, Windows 8 321
Windows 8 ( -
, Windows Phone, -
, - ) -
, .
,
, , -
.
, -
:
1. .
2. .
3. .
4. .
5. .
1.
:
, ( ) -
.
( -
), . , -
(
), :
?
?
, ?
, :
?
? ,
, , ?
,
-
?
, / -
, .
322 23
. -
.
, ?
? -
, , 1015 ? , ,
, , ?
-
.
, . " ", -
, ,
-
, , .
-
.
?
, ?
, , ,
, , ? ,
,
, ,
?
, , -
! ? ? ?
?
, -
, , , , ,
(), -
, .
- :
?
, -
, :
?
?
?
, Windows 8 323
?
- ?
. , . 23.1.
. 23.1.
-
. -
,
. , -
,
, .
, - (
., . .), () -
. , -
, (, ,
, ),
(. 23.1).
, .
23.1.
. . .
. . .
. . .
324 23
2. ?
, , , -
, .
, -
.
, , , -
(, "" "
").
, ,
( "best at
statement"). "Best at statement" ,
, , .
, :
" ".
" ".
1) , 2) 3) -
. ,
.
, , "
", ,
, , , , -
. , -
, , - -
( -
).
: " online-
" , , , ( ) -
,
, ,
, ,
( ,
), .
, , -
(, ) -
: .
!
.
- ,
- , ,
, Windows 8 325
. ,
: , -
.
, -
: " -
".
,
, , -
( ).
Best = focus. ,
, .
3.
, -
, -
.
, "", (
" "), -
, .
: ?
:
?
?
. ,
, .
( /),
, ( -
,
).
(. 23.2).
, "" , -
.
, .
-
, ,
. , , -
326 23
-
( )
(. 23.3).
. 23.2.
. 23.3.
/ ,
. ,
"best at statement" (. 23.4).
, ,
, "" (
, , ), -
, .
, , ,
, ,
( ),
.
, Windows 8 327
, /
, , ,
. . .
, ,
, - , -
.
. 23.4.
- -
, -
, ,
.
, , . -
,
.
: 1) -
; 2) ;
3) .
,
- , , -
, ( -
, ).
, "" ,
.
, , -
.
. ,
- , ( ) -
. , -
328 23
() . ,
,
.
"" ,
.
(-
) .
-
.
., , " 7". " -
", . ( -
), Movie Meeting,
-
.
8 . , . .
.
. , , -
.
Movie Meeting
.
( , ). ,
, , -
, -
(. 23.5).
, ,
. , , .
,
.
("best at statement").
. -
, , .
, ,
-
(content/features provider
scenario provider).
, Windows 8 329
. 23.5.
4.
, ,
-
- . , -
. ,
.
, -
, -
.
( ).
. 23.6.
, , -
Windows 8,
: , ,
, -
, (, , , . .).
: , -
, , ,
-
Windows 8.
330
. 23.6.
23
, Windows 8 331
. , .
, ,
. ,
, ,
, , ,
. ,
.
, "" ,
/. - -
():
, .
, -
.
Movie Meeting
:
1. : .
2. : .
3. .
4. .
5. : .
6. : .
7. : , , .
8. + : .
, ,
, -
, ( )
(. 23.7).
"" , -
(Actions).
, - ,
-,
.
, ,
Windows 8.
"
Metro" : http://msdn.microsoft.com/ru-RU/library/windows/
apps/hh761500.
332 23
. 23.7.
,
.
Windows 8. ( ),
. -
, , . .
Susan Weinschenk
"The Psychologists View of UX Design"1: "People will do the least amount of work
possible to get a task done. It is better to show people a little bit of information and let
them choose if they want more details. The fancy term for this is progressive disclosure."
" -
.
, . progressive
disclosure ( )."
, ,
.
, ,
( , ,
).
Windows 8 : -
. , Master-
1
http://uxmag.com/articles/the-psychologists-view-of-ux-design.
, Windows 8 333
Details, , , "",
.
,
,
, .
,
, .
510 ,
, , ,
( ) .
, , -
"", (
) .
, ,
, , .
, -
(. 23.8).
. 23.8.
,
. ,
.
334 23
-
.
(3 . 23.9) -
"" (4 . 23.9). -
(-
5 . 23.9).
. 23.9.
-
.
-
(
, Navigation Bar),
, ,
(. 23.10).
, ,
.
, -
(, ), IM, , -
. ., -
.
-
. , Bing News
,
, -
(. 23.11 23.12).
(Semantic Zoom). Windows 8
, -
, Windows 8 335
. 23.10.
(, ). -
,
, ,
(. 23.13).
, -
(. 23.14).
( ) , -
.
, - .
, -
,
.
, (. 23.15).
336 23
. 23.13. ,
. 23.14.
. 23.15.
338 23
" ", -
, , Windows Phone:
()
- . , -
, () .
. ,
, .
, ,
, (Snapped Mode),
. (-
, ) -
.
Windows 8 , -
.
, Windows 8 339
, Movie Meeting, -
:
.
.
.
-
, ( /) -
.
.
, ,
, (. 23.17):
" " .
" //" -
""
.
" "
( , ).
. 23.17.
, -
(Landing Page) , ,
. , -
.
() -
( ) -
, ,
, , -
/ -
.
-
(. 23.18).
,
, (. 23.19).
340 23
. 23.18.
. 23.19.
, Windows 8 341
-
.
, , , -
:
() ;
( ,
, , -
);
;
/;
, ( ), -
, ;
, ;
;
-
;
;
( -
).
, , ,
.
,
, , .
(. 23.20).
. 23.21 , .
:
();
()
, . . " ";
,
( , ),
.
, .
342
. 23.20.
23
, Windows 8 343
. 23.21.
344 23
5.
, ,
.
() , , !
, ( -
: , ).
-
, ,
,
.
, -
.
, .
,
. " ", -
. . (. 23.22).
. 23.22.
(. 23.23).
, (-
) , , .
. -
, .
,
.
-
. , -
-
(. 23.24).
, Windows 8 345
. 23.23.
. 23.24.
. 23.24 -
.
:
(
), . . .
,
, . . .
( , , )
: ,
.
346 23
, -
( ) . ,
, Web- . -
Lenovo, ,
(. 23.25).
. 23.25.
-
.
, .
Windows 8 ,
. 23.26.
, ? , , :
( , )
"".
. 23.26. Windows 8
, Windows 8 347
, , ,
. Windows 8 :
+ ;
.
, , -
, (. 23.27).
. 23.27.
,
( ),
(
).
,
, , .
, ,
: (
) , , . -
() "",
.
"-
" (Charms), , .
, "-" -
. -
:
,
Search ( inline-, -
348 23
, , -
).
,
, -
Share. (
, .)
, Settings. -
, Windows Store
, -
(,
).
,
(, )
"" (Devices).
-
, .
-
. , "-
".
() -
, ( ).
-
( , ) , -
.
, "" -
. :
.
( )
(. 23.28).
, ( -
), (), ( -
) .
, .
. (
, ) (. 23.2).
- , -
:
?
?
""
, .
, Windows 8 349
23.2.
(Full & Fill Mode) (Snapped Mode)
( - 03 02
!)
07 (3+4, 2+5) 05
, ,
. 23.28.
" " -
.
, ( ) -
// . .
, ,
, :
, (),
, ?
?
?
?
, , .
350 23
-
. 23.2.
Movie Meeting. -
.
-
? , . , -
,
.
()? :
(. 23.29):
;
( Web-).
. 23.29.
(. 23.30):
- , ;
(, );
/;
;
.
( )?
:
:
;
;
;
;
.
, Windows 8 351
:
.
, , ""
. -
.
. 23.30.
-
.
(. 23.31):
, -
.
, (,
- ).
. 23.31.
352 23
,
.
:
-
.
-
.
. -
.
(. 23.32):
,
, .
- , -
, -
(Invite+) .
/ . ,
. ,
, -
.
, .
"" .
:
,
.
. 23.32.
, Windows 8 353
. ,
,
, .
, -
, ,
, -
, -
.
,
:
.
- ,
.
,
.
?
"best at statement".
- ,
.
.
- , .
,
-
.
.
.
, -
. -
, , ,
.
.
, .
, , ,
.
, . -
, ( , ,
).
Taa24
Windows Store
Windows Store Windows 8 (. 24.1),
,
, Windows 8.
Windows 8 (Developer Preview,
Consumer Preview Release Preview) Microsoft
16 , 7 Release Preview.
Windows 8
7 , ,
Windows Store , -
, , , .
Windows Store, -
. $49 -
$99 . -
DreamSpark (http://www.dreamspark.ru).
Windows Store
(). , ,
. ,
, -
, . , -
, .
,
. -
, ,
Windows Store . -
, .
, Windows Store,
.
: -
. API
- (Trial) : (-
) ( -
). - , -
.
.
Windows Store (In-App
Purchases) API. , -
.
.
Windows Store -
. -
,
Microsoft.
, . , , -
$25 000, 70/30: 70% , 30% Microsoft.
$25 000, 80%
.
. Microsoft
"" Microsoft Advertising
SDK .
.
356 24
Windows Store
Windows ,
(. 24.2).
, Windows 8, -
, .
Windows Store : -
(, , . .) -
.
. . 24.3 "".
. 24.2.
. 24.3. ""
Windows Store 357
, Windows Store , ,
-, " ".
, , -
: , . . (. 24.4).
. 24.4.
. 24.5.
358 24
,
(. 24.5).
Windows Store
, , Windows 8. :
Windows;
Windows Pro;
Windows RT.
PC
(x86/x64),
ARM, , , -
. , Windows RT, , , .
Windows Windows Pro Windows-
Windows Store-. ,
"Designed for Windows 7" - ,
Windows 8, .
Windows RT . ARM-
Windows-
( Windows RT ).
, Windows Store- Microsoft
Windows/Windows Pro, Windows RT.
Windows Store-, C++ -
(Native) ,
Windows Store. ,
Windows RT, , -
Windows Store.
, Windows RT ARM-
MS Office, .
, Windows Store-,
, Windows 8
.
Windows Store
Windows Store :
1. Microsoft Account ( Live ID). Microsoft
Account, . Microsoft
Account .
. , Microsoft Account ,
/ .
Windows Store 359
2. , , -
. ,
- ,
. -
,
.
3. , , -
Windows Store.
, Microsoft Account.
, . -
Windows:
DreamSpark;
BizSpark;
MSDN ( Visual Studio Professional, Test Professional,
Premium Ultimate).
MSDN ,
"Subscription Benefits" MSDN-
"Windows Store developer account". -
() Windows Store. -
610 .
Windows Store :
https://appdev.microsoft.com/StorePortals/Account/Signup/Start.
Microsoft Account. -
Windows ( ) Microsoft Account
(Security Code).
. -
"" Microsoft Account.
.
, "I trust this PC"
(-
Cookies).
(. 24.6).
, , -
, .
, . . -
.
. Individual (
), Company ( ).
, . .
,
360 24
. 24.6.
. ,
Windows- . ,
, -
:
enterpriseAuthentication Windows -
;
sharedUserCertificates
- ;
documentsLibrary -
, , .
. -
Windows Store. , ,
,
Windows Store. , -
" ".
,
, . , ,
, .
-
.
, , -
, .
Web- Web-,
. ,
Windows Store 361
, ,
.
(Publisher Display Name) , -
-
. , -
-
. , . .
Windows Store. -
, ,
.
, -
. -
,
.
-
.
VAT ID ( )
(), .
(Approver) Microsoft -
, -
, Approver info.
Approver info -
.
, -
Microsoft, Symantec GeoTrust.
, .
,
(, , ). -
.
.
(), . -
.
!
, !
,
Windows Store.
-
. -
-
362 24
. ,
.
. -
.
https://appdev.microsoft.com/
StorePortals/en-us/Home ,
, , , .
Purchase ().
, Dashboard ( -
) (. 24.7).
! !
. 24.7.
.
. :
Windows ,
.
.
Windows Store 363
, -
, , , -
.
Submit an app.
App name. App name -
. Reserve
app name.
,
. 21
. .
Windows Store
Windows Store,
Visual Studio Express STORE | Create App Packages...
PROJECT | Store | Create App Packages ... Visual Studio.
. 24.8.
364 24
. 24.9.
Windows Store .
, , , -
,
. Visual Studio Windows App Certification Kit
(WACK), ,
. -
, .
WACK ,
Windows Store 365
. -
Windows Store WACK (. 24.10).
WACK, -
Windows Store. WACK -
(. 24.11).
Windows Store. Dashboard,
Submit an app. -
, . . .
. 24.11. WACK
366 24
-
, -:
( ) . -
- .
, - -
, "" -
.
LicenseInformation. -
CurrentApp,
CurrentAppSimulator ( 24.1). CurrentApp ,
Windows Store.
24.1.
CurrentAppSimulator
WindowsStoreProxy.xml, :
<__>\Microsoft\Windows Store\ApiData
WindowsStoreProxy.xml 24.2.
24.2. WindowsStoreProxy.xml
<IsActive>true</IsActive>
<IsTrial>true</IsTrial>
<ExpirationDate>2012-12-01T01:00:00.00Z</ExpirationDate>
</App>
</LicenseInformation>
</CurrentApp>
WindowsStoreProxy.xml. XML-
, LicenceInfo.xml (. 24.12).
. 24.12.
LicenceInfo.xml
LicenceInfo.xml WindowsStoreProxy.xml.
LicenceInfo.xml -
WindowsStoreProxy.xml ( 24.3).
LicenceInfo.xml ( AppId). -
Packaging.
368 24
24.3. WindowsStoreProxy.xml
LicenceInfo.xml
WindowsStoreProxy.xml. IsTrial
LicenseInformation , -. -
- , ,
( 24.4).
24.4. -
if (licenseInformation.IsActive)
{
if (licenseInformation.IsTrial)
{
var remaining = licenseInformation.ExpirationDate DateTime.Now;
}
else
{
// ...
}
}
CurrentApp CurrentAppSimulator
-, (In-App
Purchases). .
Windows Store ,
. ,
. -
Windows Store 369
XAML
1.1. Foo
namespace FooNamespace
{
public class Foo
{
public string SomeText { get; set; }
}
}
Foo SomeText.
C# ( 1.2).
1.3 .
XAML-, C#,
. C#-
using.
, FooUser Foo,
( 1.4).
1.4. FooUser
using FooNamespace;
namespace SomeNamespace
{
public class FooUser
{
public FooUser()
{
Foo foo = new Foo();
foo.SomeText = " ";
}
}
}
FooUser Foo , -
. XAML-
. XML xmlns.
XAML- XML
Windows Runtime . 1.5
Foo
FooNamespace. ,
, -
.
1.5.
!
-
, .
XAML 375
<Page
x:Class="XAMLApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XAMLApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource
ApplicationPageBackgroundThemeBrush}">
</Grid>
</Page>
( 1.7) -
"x" ( 1.8).
1.7.
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
1.8. "x"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
XML, . -
, , -
Windows Runtime.
.
,
Grid, StackPanel , .
-
- .
"x" (x:Name), (x:Key),
(, x:Null -
NULL).
XAML- , -
, .
376 1
XAML XML XAML .
,
. 1.3 SomeText .
( 1.9).
1.9.
<FooNamespace:Foo xmlns:FooNamespace="using:FooNamespace">
<FooNamespace:Foo.SomeText>
</FooNamespace:Foo.SomeText>
</FooNamespace:Foo>
,
.
( 1.10).
1.10.
<Grid x:Name="ContentPanel"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Content="" Foreground="Yellow" Background="Blue"/>
</Grid>
"", (Foreground=
"Yellow")
(Background="Blue").
Foreground Background (-
1.11).
1.11.
<Grid x:Name="ContentPanel"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Content="">
<Button.Foreground>
<SolidColorBrush Color="Yellow"/>
</Button.Foreground>
<Button.Background>
<SolidColorBrush Color="Blue"/>
</Button.Background>
</Button>
</Grid>
XAML 377
C# ( 1.12).
1.12.
,
Text ( ), Content. -
, . -
.
, -
CheckBox, RadioButton TextBox. RadioButton
( 1.13, . 1.1).
. 1.1.
1.13.
<Button>
<Button.Content>
<StackPanel>
<CheckBox Content="CheckBox"/>
<RadioButton>
<StackPanel>
<Button Content=" 1" />
<Button Content=" 2" />
<Button Content=" 3"/>
378 1
</StackPanel>
</RadioButton>
<TextBox />
</StackPanel>
</Button.Content>
</Button>
-
. Content.
<Button.Content> . -
1.13 <RadioButton.Content> .
, . XAML-
.
, Foreground FontSize (-
1.14).
1.14.
,
.
(TargetType="Button").
, (x:Key="buttonStyle").
buttonStyle , Style ( 1.15).
1.15.
1.16.
XAML 379
1.16.
<Page
...
>
<Page.Resources>
<Style TargetType="Button" x:Key="buttonStyle">
<Setter Property="FontSize" Value="48"/>
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="Yellow"/>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<Grid x:Name="ContentPanel"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Content="" Style="{StaticResource buttonStyle}"/>
</Grid>
</Page>
. -
. , -
buttonStyle ( 1.17).
1.17.
BasedOn.
, -
, . -
. -
, .
. -
,
x:Key. 1.18
(. 1.2).
1.18.
<Page
...
>
380 1
<Page.Resources>
<Style TargetType="Button" x:Key="buttonStyle">
<Setter Property="FontSize" Value="48"/>
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="Yellow"/>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Button"
BasedOn="{StaticResource buttonStyle}">
<Setter Property="Background" Value="Blue"/>
</Style>
</Page.Resources>
<Grid x:Name="ContentPanel"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<StackPanel x:Name="LayoutRoot" Background="Transparent">
<Button Content=" 1"/>
<Button Content=" 2" Style="{x:Null}"/>
<Button Content=" 3"/>
</StackPanel>
</Grid>
</Page>
. 1.2.
,
, -
.
(Style="{x:Null}").
, , -
App.xaml.
( 1.19).
1.19. App.xaml
<Application
x:Class="XAMLApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
XAML 381
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XAMLApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<Style TargetType="Button" x:Key="buttonStyle">
<Setter Property="FontSize" Value="48"/>
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="Yellow"/>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Button"
BasedOn="{StaticResource buttonStyle}">
<Setter Property="Background" Value="Blue"/>
</Style>
</ResourceDictionary>
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
XAML-
. -
. 1.18
, 1.19 . -
, . 1.20
.
1.20.
</Setter>
</Style>
</Button.Resources>
</Button>
App.xaml, .
XAML-, .
Styles.xaml Resource Dictionary
,
( 1.21).
1.21. Styles.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button" x:Key="buttonStyle">
<Setter Property="FontSize" Value="48"/>
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="Yellow"/>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Button"
BasedOn="{StaticResource buttonStyle}">
<Setter Property="Background" Value="Blue"/>
</Style>
</ResourceDictionary>
App.xaml (-
1.22).
1.22.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml"/>
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
XAML 383
!
,
StandardStyles.xaml, .
, .
.
, , .
.
, ,
, Windows 8. ,
. . XAML -
.
1.23 (. 1.3).
1.23.
ContentPresenter.
. 1.3.
384 1
,
, . -
.
1.23
. , .
VSM (Visual State Manager),
9.
, , XAML-
( 1.24), , .
1.24.
<Page
...
>
<Page.Resources>
<ControlTemplate x:Key="buttonTemplate" TargetType="Button">
<Grid>
<Ellipse Stroke="{StaticResource
ApplicationForegroundThemeBrush}"
StrokeThickness="4" StrokeDashArray="4 2"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"/>
<ContentPresenter VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Page.Resources>
<Grid x:Name="ContentPanel"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Content="" Width="350" Height="100"
Template="{StaticResource buttonTemplate}"/>
</Grid>
</Page>
,
,
.
:
Canvas;
StackPanel;
Grid.
XAML 385
Canvas .
-
. Canvas -
(Attached Properties),
. Canvas.Top -
Button, -
Canvas.
(Button) Canvas , 1.25.
1.25. Canvas
<Canvas>
<Button Canvas.Top="75" Canvas.Left="75" Content=" T75.L75.Z-1"
Canvas.ZIndex="-1" FontSize="18" Width="200"
Height="75" Background="Orange" />
(. 1.4).
,
Canvas.
. 1.4. Canvas
386 1
!
, ZIndex, ,
.
Canvas ,
, , -
-
.
Canvas ,
Grid StackPanel. Canvas -
.
StackPanel , -
-
( ). StackPanel
( 1.26).
1.26. StackPanel
<StackPanel>
<Button Margin="0,0,0,10" Content=" 0.0.0.10"
FontSize="18" Width="200" Height="75" />
<Button Content=" 0.0.0.0" FontSize="18"
Width="200" Height="75" />
<Button Margin="0,50,0,0" Content=" 0.50.0.0"
FontSize="18" Width="200" Height="75" />
<Button Margin="150,170,0,0" Content=" 150.170.0.0"
FontSize="18" Width="200" Height="75" />
</StackPanel>
Visual Studio, . -
Margin, -
.
StackPanel ,
. 1.5.
StackPanel ( 1.27).
1.27. StackPanel
<StackPanel Orientation="Horizontal">
<Button Margin="0,0,0,10" Content=" 0.0.0.10"
FontSize="18" Width="200" Height="75" />
<Button Content=" 0.0.0.0" FontSize="18"
Width="200" Height="75" />
XAML 387
, . 1.6.
. 1.5.
StackPanel
. 1.6. StackPanel ( )
Grid -
. Grid
. Grid -
, , ,
.
388 1
1.28.
1.28. Grid
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
!
, (Grid.Row) (Grid.Column) -
.
:
;
, (Auto);
(*).
, 200 ,
, , , -
.
. 1.7.
, -
Grid.RowSpan.
Grid.ColumnSpan. -
1.29 , .
XAML 389
. 1.7. Grid
<Button Content=""
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Grid.RowSpan="2" Grid.ColumnSpan="3" />
, -
. -
- . -
, . -
Binding.
, -
, ,
.
.
390 1
-
( 1.30).
1.30.
<StackPanel>
<Slider x:Name="slValue" />
<TextBox Text="{Binding Path=Value, ElementName=slValue}"/>
</StackPanel>
:
="{Binding ___}"
. 1.8.
, . ,
.
(Mode=TwoWay) ( 1.31).
1.31.
<StackPanel>
<Slider x:Name="slValue" />
<TextBox
Text="{Binding Path=Value, ElementName=slValue, Mode=TwoWay}" />
</StackPanel>
-
.
Path ( 1.32).
XAML 391
1.32. Path
<StackPanel>
<Slider x:Name="slValue" />
<TextBox Text="{Binding Value, ElementName=slValue, Mode=TwoWay}" />
</StackPanel>
1 100. , ,
1 40 , -
40 80 , 80 100 .
(Background) , -
, . . , -
double. . -
, .
IValueConverter ( 1.33).
1.33.
IValueConverter -
: Convert ConvertBack. DoubleToBrushConvertor -
.
XAML--
( 1.34).
1.34.
<Page.Resources>
<local:DoubleToBrushConvertor x:Key="doubleToBrushConvertor"/>
</Page.Resources>
( 1.35).
1.35.
<StackPanel>
<Slider x:Name="slValue" />
<TextBox
Text="{Binding Value, ElementName=slValue, Mode=TwoWay}"
Background="{Binding Value,ElementName=slValue,
Converter={StaticResource doubleToBrushConvertor}}"/>
</StackPanel>
-
.
DataContext
- DataContext,
-
, DataContext. -
- .
, Person ( 1.36), -
(, e-mail).
1.36. Person
( 1.37).
1.37.
<StackPanel x:Name="spPerson">
<TextBox Text="{Binding FirstName}"/>
<TextBox Text="{Binding LastName}"/>
<TextBox Text="{Binding Email}"/>
</StackPanel>
Person
StackPanel spPerson ( 1.38).
1.38. DataContext
spPerson.DataContext = person;
spPerson
Person.
DataContext . ,
MVVM
(Model View ViewModel).
Person, . -
, Person .
,
INotifyPropertyChanged PropertyChanged -
( 1.39).
1.39. INotifyPropertyChanged
set
{
_lastName = value;
OnPropertyChanged("LastName");
}
}
, Person,
.
1.39 -
. ,
[CallerMemberName],
( ) ( 1.40).
XAML 395
1.40. [CallerMemberName]
storage = value;
this.OnPropertyChanged(propertyName);
return true;
}
Person. -
ObservableCollection<T>, . . , (-
, List<T>), .
ObservableCollection<T>
. -
Person ( 1.41).
1.41.
public MainPage()
{
this.InitializeComponent();
}
}
XAML 397
( 1.42).
1.42.
</ListBox>
1.42 (ItemsSource)
ListBox Persons . -
MainPage, ListBox
Persons MainPage.
, ,
Person (. 1.9).
. 1.9. Person
ListBox, -
Person ( 1.43).
1.43. ListBox
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Person,
.
(. 1.10).
. 1.10. ListBox
XAML. ,
, -
. , -
.
XAML . ,
XAML- C# ( ,
C++ Visual Basic).
XAML-. , -
, XAML-
. , ,
.
poee2
C# 5
C#, ,
. ,
, .
-
, -
. Windows 8 Windows Runtime -
. -
, ,
(. 2.1).
. 2.1.
400 2
.
Microsoft , -
. , , Silverlight WebClient, -
http,
DownloadString, DownloadStringAsync
DownloadStringCompleted -
. , , ?
WebClient "" .
WPF- -
MainWindow.xaml ( 2.1).
<Window x:Class="WpfApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="600" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox x:Name="txtResult"
Grid.Row="0" AcceptsReturn="True" Margin="10"/>
<Button Content=""
Grid.Row="1" Width="250" Margin="10" Click="Button_Click"/>
</Grid>
</Window>
http://akhmed.ru ( 2.2).
2.2. DownloadString
? -
. "" , .
? , -
, - ,
, (
).
, "" -
? , , (Thread)
. WebClient
DownloadStringAsync,
( 2.3).
2.3.
, . -
( 2.4).
402 2
2.4.
client.DownloadStringAsync(new Uri("http://akhmed.ru"));
}
.
, -
. , http://habrahabr.ru, http://yandex.ru http://mail.ru
( 2.5).
2.5.
client3.DownloadStringAsync(new Uri("http://mail.ru"));
};
client2.DownloadStringAsync(new Uri("http://yandex.ru"));
};
client.DownloadStringAsync(new Uri("http://habrahabr.ru"));
}
C# 5 403
. - -
,
if,
try/catch.
, ,
. , . -
,
( 2.6).
2.6. 2.5
GetLength ,
. , -
try/catch.
async await
C# 5
async await C# 5
.
, WPF-
, .NET
Framework 4.5 ( 2.7).
Async Targeting Pack for Visual Studio 2012 -
async await Silverlight 5
.NET Framework 4.0.
404 2
2.7. WPF
2.7 2.4 .
. , ,
: async await .
DownloadStringTaskAsync, Task<string>. -
(
await), .
async await Windows Store-
. Windows Store- , -
WPF .
, .
Windows 8
, .
, -
. , http Windows Store-
( 2.8).
, ? -
, async await.
C# 5 405
, async await,
Task Task<T>, .
GetStryngAsync Task<string>,
, string.
, -
Wait ( 2.9).
2.9.
, ,
"" , . -
await ( 2.8),
. Button_Click ,
. Button_Click,
await, .
.
.
async await, (-
2.10).
2.10.
txtResult.Text = length.ToString();
}
406 2
, .
, .
Task -
. , -
, , . Task
WhenAll, -
( 2.11).
2.11.
txtResult.Text = length.ToString();
}
. -
, . .
,
,
Task.Factory ( 2.12) ,
await.
2.12.
, -
. -
. ( ) Windows Store-
.
C# 5 407
async await C# 5 -
. Task
Task<T>. Windows 8 , -
( 50 ), ,
,
.
, . -
, , -
. , async await -
. .
, , ,
.
A DeviceInformation 256
DLL- 142
Accelerometer 279
DreamSpark 355
Animation Library 316
Application Bar 12, 18, 77
ApplicationLanguages 291 F
Assemblies 39
async 45, 403 FileIO 219
Attached Properties 385 FileOpenPicker 229
await 45, 403 FileSavePicker 232
Filled 17, 125
B Flyout 84
FolderPicker 233
BackgroundTaskBuilder 147 Frame 59
Badge 156 Frameworks 39
BadgeUpdateManager 173 Full Screen 16, 125
Bauhaus 303
"Best at statement" 324
Binding 389
G
Blend for Visual Studio 27 Geolocator 262
Global Position System, GPS 259
C Grid 387
Gyrometer 282
CachedFileManager 233
CameraCaptureUI 245
Canvas 385 I
Charms 19, 347 i18n 289
Chrome 307
In-App Purchases 355
Clipboard 198
Inclinometer 285
Compass 286
Culture 290 Information Architecture 304
CultureInfo 290 International Typographic Style 23, 303
CurrentApp 366 Internationalization 289
CurrentAppSimulator 366 ItemTemplate 102
D J
DataTransferManager 196 JSON 205
Dependency Property 94 JsonObject 205
410
L Share 194
Sharing 318
Language Integrated Quiries, LINQ 224 SimpleOrientationSensor 287
LayoutAwarePage 94, 130 Snapped 16, 125
LicenseInformation 366 Snapped Mode 338
LightSensor 276 Socket API 89
Live ID 358 SQLite 221
Live Tile 162 SQL- 227
Lock Screen 143 StackPanel 386
Storyboard 132
M Suggestions 180
Swiss Design 303
MediaCapture 256 SyndicationClient 89
Microsoft Advertising 355
Motion Design 23, 303 T
MVVM 393
Task 405
O Task<T> 405
Tile 19, 156
Object-Relational Mapping, ORM 224 TileUpdateManager 168
TileUpdater 166
Toast 156
P Toast Notification 151
Pivots 338 Trial 355
Pixels Per Inch, PPI 133
Popup 84, 213 U
PopupMenu 85
Push Notification 155 User Account Control, UAC 181
Push- 151
V
R Visual State Manager, VSM 28, 132
RandomAccessStreamReference 202 Visual Studio 26
Raw 156
Remote Desktop 46 W
Resource leak 278
Windows App Certification Kit, WACK 364
S Windows Push Notification Services, WNS
142, 156
SampleDataSource 88 Windows Runtime 15, 21
Sandbox 216 WinRT 21
SearchPane 187 WnsRecipe 161
Secondary Tiles 20, 162, 177 WYSIWYG 40
Security Code 359
Semantic Zoom 115, 312, 334 X
Sensor Fusion 283
Settings 209 XAML-
SettingsCommand 211 41
SettingsPane 209 SecondPage.xaml 56
411
344
307
60 115, 312,
315 334
163 307, 344
181
348
347
290
Bing Maps SDK 267 291
NotificationsExtensions 168
SQLite for Windows Runtime 222
sqlite-net 224
31
WnsRecipe 161
289
316
360
356
384
309 Canvas 385
Grid 387
StackPanel 386
173, 174 85, 345
290 347
103 256
- 366 308, 332
333
24 334
25
301
303
"" 313
307
318
338 83, 213
316, 338
173
304, 329 "" 216
338
316, 338
177
256 166, 175
293 170
412
19
188
191 151
348 155
374 158
375 359
Windows Store 32
181
Filled 17 App.xaml 36, 380
Full Screen 16 App.xaml.cs 37, 137, 182, 236
Snapped 16 LicenceInfo.xml 367
121 MainPage.xaml 35
115 MainPage.xaml.cs 35, 41
115 Package.appxmanifest 37, 182, 199, 291
162 SampleDataSource.cs 88
16, 125 StandardStyles.xaml 37, 81
Vsix 267
249
WindowsStoreProxy.xml 366
142
382 229
294
232
310
325
389
WNS 156 251
304
250
344
137
FutureAccessList.Add 239
378
GetDefault() 279
379
PostToWns 159
58
405
72
325
"-" 19
- 15
71
28, 70 Basic Page 56, 62
24 Grid App 70, 87
198 152
163
144 114
145 383
413
(.)
32
163
102 SQL 221
384 292
305 301
315
143
321