View
678
Download
0
Category
Preview:
Citation preview
Hello Windows 10gillcleerennicovermeir
httpwindowsMicrosoftcom
About GillGill CleerenMicrosoft Windows Platform MVP amp Regional DirectorOrdina architect ndash Practice ManagerPluralsight authorSpeakerBook author
gillcleerengillsnowballbewwwsnowballbe
httpwindowsMicrosoftcom
About NicoNico VermeirMicrosoft Windows Platform MVP
RealDolmen software engineer NET Mobile
Speaker
Book author
NicoVermeir
nico_vermeirhotmailcom
httpwwwspikiebe
httpwindowsMicrosoftcom
Agendabull The Story of 10 bull XAML then and now bull Data binding improvements bull Adaptive adaptive and more adaptive bull New in Live Tiles bull The App Lifecyclebull (Optional) App-to-App communication bull (Optional) App Services
Introducing the UWP
httpwindowsMicrosoftcom
Windows CoreThe refactored common coreOne hardware platformUniversal hardware driverStandard network and IO
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
DesktopSKU
PhoneSKU
XboxSKU
httpwindowsMicrosoftcom
One Windows
DesktopSKU
PC
2 in 1
MobileSKU
Tablet
Phablet
Phone
XboxSKU
Xbox
IoTSKU
Band
IoT headless
SKU
Raspberry Pi
Home Automati
on
Surface HubSKU
Surface Hub
HolographicSKU
HoloLens
Each family adds features to the one it inherits
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
About GillGill CleerenMicrosoft Windows Platform MVP amp Regional DirectorOrdina architect ndash Practice ManagerPluralsight authorSpeakerBook author
gillcleerengillsnowballbewwwsnowballbe
httpwindowsMicrosoftcom
About NicoNico VermeirMicrosoft Windows Platform MVP
RealDolmen software engineer NET Mobile
Speaker
Book author
NicoVermeir
nico_vermeirhotmailcom
httpwwwspikiebe
httpwindowsMicrosoftcom
Agendabull The Story of 10 bull XAML then and now bull Data binding improvements bull Adaptive adaptive and more adaptive bull New in Live Tiles bull The App Lifecyclebull (Optional) App-to-App communication bull (Optional) App Services
Introducing the UWP
httpwindowsMicrosoftcom
Windows CoreThe refactored common coreOne hardware platformUniversal hardware driverStandard network and IO
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
DesktopSKU
PhoneSKU
XboxSKU
httpwindowsMicrosoftcom
One Windows
DesktopSKU
PC
2 in 1
MobileSKU
Tablet
Phablet
Phone
XboxSKU
Xbox
IoTSKU
Band
IoT headless
SKU
Raspberry Pi
Home Automati
on
Surface HubSKU
Surface Hub
HolographicSKU
HoloLens
Each family adds features to the one it inherits
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
About NicoNico VermeirMicrosoft Windows Platform MVP
RealDolmen software engineer NET Mobile
Speaker
Book author
NicoVermeir
nico_vermeirhotmailcom
httpwwwspikiebe
httpwindowsMicrosoftcom
Agendabull The Story of 10 bull XAML then and now bull Data binding improvements bull Adaptive adaptive and more adaptive bull New in Live Tiles bull The App Lifecyclebull (Optional) App-to-App communication bull (Optional) App Services
Introducing the UWP
httpwindowsMicrosoftcom
Windows CoreThe refactored common coreOne hardware platformUniversal hardware driverStandard network and IO
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
DesktopSKU
PhoneSKU
XboxSKU
httpwindowsMicrosoftcom
One Windows
DesktopSKU
PC
2 in 1
MobileSKU
Tablet
Phablet
Phone
XboxSKU
Xbox
IoTSKU
Band
IoT headless
SKU
Raspberry Pi
Home Automati
on
Surface HubSKU
Surface Hub
HolographicSKU
HoloLens
Each family adds features to the one it inherits
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Agendabull The Story of 10 bull XAML then and now bull Data binding improvements bull Adaptive adaptive and more adaptive bull New in Live Tiles bull The App Lifecyclebull (Optional) App-to-App communication bull (Optional) App Services
Introducing the UWP
httpwindowsMicrosoftcom
Windows CoreThe refactored common coreOne hardware platformUniversal hardware driverStandard network and IO
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
DesktopSKU
PhoneSKU
XboxSKU
httpwindowsMicrosoftcom
One Windows
DesktopSKU
PC
2 in 1
MobileSKU
Tablet
Phablet
Phone
XboxSKU
Xbox
IoTSKU
Band
IoT headless
SKU
Raspberry Pi
Home Automati
on
Surface HubSKU
Surface Hub
HolographicSKU
HoloLens
Each family adds features to the one it inherits
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Introducing the UWP
httpwindowsMicrosoftcom
Windows CoreThe refactored common coreOne hardware platformUniversal hardware driverStandard network and IO
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
DesktopSKU
PhoneSKU
XboxSKU
httpwindowsMicrosoftcom
One Windows
DesktopSKU
PC
2 in 1
MobileSKU
Tablet
Phablet
Phone
XboxSKU
Xbox
IoTSKU
Band
IoT headless
SKU
Raspberry Pi
Home Automati
on
Surface HubSKU
Surface Hub
HolographicSKU
HoloLens
Each family adds features to the one it inherits
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Windows CoreThe refactored common coreOne hardware platformUniversal hardware driverStandard network and IO
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
DesktopSKU
PhoneSKU
XboxSKU
httpwindowsMicrosoftcom
One Windows
DesktopSKU
PC
2 in 1
MobileSKU
Tablet
Phablet
Phone
XboxSKU
Xbox
IoTSKU
Band
IoT headless
SKU
Raspberry Pi
Home Automati
on
Surface HubSKU
Surface Hub
HolographicSKU
HoloLens
Each family adds features to the one it inherits
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
One Windows
DesktopSKU
PC
2 in 1
MobileSKU
Tablet
Phablet
Phone
XboxSKU
Xbox
IoTSKU
Band
IoT headless
SKU
Raspberry Pi
Home Automati
on
Surface HubSKU
Surface Hub
HolographicSKU
HoloLens
Each family adds features to the one it inherits
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Each family adds features to the one it inherits
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Easy for users to get amp stay
current
Unified core and app platform
The convergence journey
Windows Phone 75
Windows Phone 8Windows Phone 81
Windows 8
Xbox One
Windows on Devices
Xbox 360
Windows 81
Windows 10
ConvergedOS kernel
Convergedapp model
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Phone Small Tablet
2-in-1s(Tablet or Laptop)
Desktops amp All-in-OnesPhablet Large Tablet
Classic Laptop
Xbox IoTSurface Hub
Holographic
Windows 10
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Multiple device families
PC XBoxMobile Surface Hub
HoloLensDevices +IoT
Universal Windows Apps
One Store +One Dev Center
Reuse Existing CodeOne SDK +
Tooling
Adaptive User Interface Natural
User Inputs
One Universal Windows Platform
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Universal Windows PlatformA single API surfaceA guaranteed API surfaceThe same on all devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Windows appA single binary Running on any deviceTesting for capabilitiesAdjusting to devices
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
The developer storyWhen writing for iOS A developer writes for iPad amp iPhone
When writing for Android A developer writes for all supported devices
When writing for Windows 8 A developer writes for each devices
When writing for Windows 10 A developer writes for every device
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOHello World
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Platform extensionsDevice-specific APIFamily-specific capabilitiesCompatible across devicesUnique update cadence
PhoneDevice
XboxDevice
DesktopDevice
Windows Core
Universal Windows Platform
Windows App
Phoneextension
Xboxextension
Desktop
extension
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Extensions dont invalidate binaries on other devices
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
UAP
Windows Core Windows Core Windows Core Windows Core
UAP UAP UAP
Desktop Mobile Xbox Morehellip
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Test capabilities at runtimeUse Adaptive Code to light-up your app on specific devicesvar api = WindowsPhoneUIInputHardwareButtonsif (WindowsFoundationMetadataApiInformationIsTypePresent(api))
WindowsPhoneUIInputHardwareButtonsCameraPressed += CameraButtonPressed
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Windows 10operating system
Bridging technologies
Win32
desktop
Webhosted
JavaAndroid
ObjCiOS
Universal Windows Platform
WWAC++amp CX
Netlanguages
HTMLDirectXXAML
C++
Netlanguages
MFCWFWPF
Netruntime
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
XAML then and now
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Windows 810 Layout controlsltBorder Thickness= Brush= gt
ltCanvas gt
ltGrid gt
ltRelativePanel gt
ltScrollViewer gt
ltSplitView DisplayMode= gt
ltStackPanel Orientation= gt
ltVariableSizedWrapGrid gt
ltViewBox Stretch= gt
New in Win10
New in Win10
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
RelativePanelDefines an area within which you can position and align child objects in relation to each other or the parent panel
RelativePanel is a constraint based layout container that you can use to create UIs by expressing spatial relationships between elements
Using RelativePanelrsquos attached properties you can position a UI element relative to another UI element (A is RelativePanelBelow B) as well as relative to the panel (A is RelativePanelAlignTopWithPanel)
-MSDN
New in Win10
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
RelativePanelSome child elementsact as anchorsMost child elementsrelate to othersIts a layout techniquefriendly with States
See Adaptive Triggers later
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Important propertiesAttached propertiesbull Above amp Below bull AlignBottomWith amp AlignTopWith bull AlignBottomWithPanel amp AlignTopWithPanel bull AlignHorizontalCenterWith amp AlignVerticalCenterWith bull AlignHorizontalCenterWithPanel amp AlignVerticalCenterWithPanel bull AlignLeftWith amp AlignRightWith bull AlignLeftWithPanel amp AlignRightWithPanel bull LeftOf amp RightOf
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder Width=100 Height=100 Background=Blue RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=TruegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAbove=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Some RelativePanel samples
ltRelativePanelgt ltBorder xName=ElementOne Width=200 Height=200 Background=Red RelativePanelAlignHorizontalCenterWithPanel=True RelativePanelAlignVerticalCenterWithPanel=Truegt ltBorder xName=ElementTwo Width=100 Height=100 Background=Blue RelativePanelAlignBottomWith=ElementOnegtltRelativePanelgt
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Some RelativePanel samplesltRelativePanel BorderBrush=Gray BorderThickness=10gt ltRectangle xName=RedRect Fill=Red MinHeight=100 MinWidth=100gt ltRectangle xName=BlueRect Fill=Blue MinHeight=100 MinWidth=100 RelativePanelRightOf=RedRect gt ltRectangle xName=GreenRect Fill=Green MinHeight=100 Margin=0500ldquo RelativePanelBelow=RedRect RelativePanelAlignLeftWith=RedRect RelativePanelAlignRightWith=BlueRectgt ltRectangle Fill=Yellow MinHeight=100 RelativePanelBelow=GreenRect RelativePanelAlignLeftWith=BlueRect RelativePanelAlignRightWithPanel=Truegt ltRelativePanelgt
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMORelativePanel
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
We wanted this for a long time
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Now available the SplitViewltSplitView xName=SplitView Background=Black OpenPaneLength=240 CompactPaneLength=48 DisplayMode=CompactOverlay IsPaneOpen=False Content=Bindinggt ltSplitViewPanegt ltStackPanel xName=SplitViewPanePanelgt ltRadioButton xName=BackRadioButton Click=BackRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Back GroupName=Backgt ltRadioButton xName=HamburgerRadioButton Click=HamburgerRadioButton_Click
Style=StaticResource NavRadioButtonStyle Content=Menu GroupName=Hamburgergt ltStackPanelgt ltSplitViewPanegtltSplitViewgt
New in Win10
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
SplitView IsPaneOpen=True IsPaneOpen=False
DisplayMode=Inline
DisplayMode=Overlay
DisplayMode=CompactInline
DisplayMode=CompactOverlay
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Sample SplitView ltSplitView xName=MySplitView DisplayMode=CompactOverlay IsPaneOpen=False CompactPaneLength=50 OpenPaneLength=150gt ltSplitViewPanegt ltStackPanel Background=Graygt ltButton xName=HamburgerButton FontFamily=Segoe MDL2 Assets Content=ampxE700 Width=50 Height=50 Background=Transparent Click=HamburgerButton_Clickgt ltStackPanel Orientation=Horizontalgt ltButton xName=MenuButton1 FontFamily=Segoe MDL2 Assets Content=ampxE825 Width=50 Height=50 Background=Transparentgt ltTextBlock Text=Button 1 FontSize=18 VerticalAlignment=Center gt ltStackPanelgt hellip ltStackPanelgt ltSplitViewPanegt ltSplitViewContentgt ltGridgt ltTextBlock Text=SplitView Basic FontSize=54 Foreground=Whitegt ltGridgt ltSplitViewContentgtltSplitViewgt
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
The resulting SplitView
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOSplitView
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
ButtonsltButton Content= gt
ltHyperlinkButton gt
ltRepeatButton gt
ltToggleButton IsChecked= gt
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Text controlsltTextBox Text= gt
ltPasswordBox Text= gt
ltTextBlock Text= gt
ltAutoSuggestBox gt
ltRichEditBox Content= gt
ltRichTextBlock Content= gt
ltBitmapIcon UriSource= gt
ltFontIcon Glyph= gt
ltSymbolIcon Icon= gt
ltPathIcon Data= gt
New in Win10
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
AutoSuggestBox New in Win10
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOText controls
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Selection and picker controlsltCalendarView gt
ltDatePicker Date= gt
ltTimePicker Time= gt
ltToggleSwitch IsChecked= gt
ltCheckBox IsCHecked= gt
ltRadioButton IsChecked= gt
ltComboBox gt
ltListBox gt
ltSlider Minimum= Maximum= gt
Win10
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
CalendarViewWindows uses this one itself
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOSelection amp pickers
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Collectiondata controlsltItemsControl ItemsSource= gt
ltFlipView gt
ltGridView gt
ltListView gt
ltSematicZoom gt
ltPivot gt
ltHub Orientation= gt
ltContentControl ControlTemplate= gt
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Pivot
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
App bars and commandsltAppBar gt
ltCommandBar gt
ltAppBarButton Label= Icon= gt
ltAppBarToggleButton IsChecked= gt
ltAppBarSeparator gt
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Flyout controlsltPopup IsOpen= gt
ltContentDialog Title= Content= gt
ltFlyout Placement= gt
ltMenuFlyout gt
ltToolTip gt
New in Win10
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
ContentDialog
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMO
Flyout controls amp ContentDialog
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Progress Media amp Inking controlsltProgressBar IsIntermediate= gt
ltProgressRing IsActive= gt
ltImage gt
ltInkCanvas gt
ltMediaElement gt
New in Win10
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
InkCanvasExtremely complex control to start using
ltGridgt lt-- Itrsquos this simple --gt ltInkCanvasgtltGridgt
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOInking
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Maps
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOMap control
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Live Visual Tree New in Win10
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOLive Visual Tree
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Data binding
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
What problem are we solving
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Classic Bindin
g
Compiled
Binding
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
xBindCompiled bindingBindings are committed at compile-time
Strongly-typed bindingDuck binding is not supported
Default mode is OneTimeOneWay and TwoWay are still available
Standard binding approachesINotifyPropertyChanged IObservableVector INotifyCollectionChanged
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
The data context of xBind is the code-behind class
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
SyntaxltTextBox Text=Binding
ConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
ltTextBox Text=xBindConverterConverterLanguageConverterParameterElementNameFallbackValueModePathRelativeSourceSourceTargetNullValueUpdateSourceTrigger
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMO
Using the Compiled binding
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
ltListView ItemsSource=xBind ViewModelEmployeesgt
ltListViewItemTemplategt
ltDataTemplate xDataType=modelEmployeegt
ltGridgt
ltTextBlock Text=xBind Namegt
ltGridgt
ltDataTemplategt
ltListViewItemTemplategt
ltListViewgt
Data Templates
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Syntax differences ltListView ItemsSource=Binding Items Header=Classic GridColumn=0gt ltListViewItemTemplategt ltDataTemplategt ltTextBlock Text=Binding Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
ltListView ItemsSource=xBind ViewModelItems xmlnsm=usingBlank3Models Header=Compiled GridColumn=1gt ltListViewItemTemplategt ltDataTemplate xDataType=mTodoItemgt ltTextBlock Text=xBind Title gt ltDataTemplategt ltListViewItemTemplategtltListViewgt
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Resource dictionariesltResourceDictionary
xClass=MyNamespaceMyTemplates
xmlnsmodel=usingxBindSampleModelgt
ltDataTemplate
xKey=MyTemplate
xDataType=modelEmployeegt
ltTextBlock Text=xBind Name gt
ltDataTemplategt
ltResourceDictionarygt
namespace MyNamespace public class MyTemplates public MyTemplates() InitializeComponent()
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Referencing a dictionaryltUserControlResourcesgt
ltResourceDictionarygt
ltResourceDictionaryMergedDictionariesgt
ltlocalMyTemplatesgt
ltResourceDictionary Source=filename gt
ltResourceDictionaryMergedDictionariesgt
ltResourceDictionarygt
ltUserControlResourcesgt
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Binding for EventsltButton Click=PokeEmployeegtPoke EmployeeltButtongt
ltButton Click=xBind EmployeePokegtPoke EmployeeltButtongt
SignatureHave no parameters - void Poke()Match event parameters - void Poke(object sender RoutedEventArgs e)Match event base types - void Poke(object sender object e)Overloading is not supported
Because all events are eligibleThis may replace ICommand amp EventToCommandNote this does not include parameter or CanExecute
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
PageViewModelpublic sealed partial class MainPage Page public MainPage() InitializeComponent() thisDataContextChanged += (s e) =gt ViewModel = DataContext as ViewModelsMainPageViewModel
strongly-typed view models enable xbind public ViewModelsMainPageViewModel ViewModel get set
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMO
Using a ViewModel declaratively
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
When to use classic bindingDuck TypingText=ldquoBinding Agerdquo works for both PersonModel amp WineModel
Dictionary graphsUse Binding with JSON or other untyped objects
Code-behind binding adding and removing bindings on the flyCan addremove xBind runtime
Use in a stylexBind canrsquot be used in a style for settersxBind can be used in a DataTemplate that is defined in the style
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
xBind is not for every situation right nowIt will in the future
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
xBind can meet your binding needs most of the time Letrsquos say around 80
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
The adaptive story
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Tailored designBuild pagescode for individual familiesUse MRT in Appxamlcs to determine the family
One-handed interfaceTypically phone or small tabletsTest diagonal screen size (lt7)
if (physical_diagonal_size lt= 7) optimized for one-handed operation rootFrameNavigate(typeof(MainPage_OneHanded) eArguments)else rootFrameNavigate(typeof(MainPage) eArguments)
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Nothing is stopping you from creating a multi-headed solution
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Dedicated targeted apps
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Adaptive tooling
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Visual StatesDefine XAML viewsUnique layout for distinct states
Simplify animationAutomatically implement state transitions
Build in BlendDesign and preview states and transitions
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMO
Visual states Adaptive triggers Custom triggers
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
How Windowsmakes design easier
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Adaptive controls
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Input intelligence
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Techniques to adapt
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Three core adaptive approachesResponsive designResize your contentReflow your content
Adaptive designReposition your contentRedesign your content
Tailored design
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Resize
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Reflow
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Reposition
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Redesign
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Dont assume you will use only one technique
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Adaptive Code and API versions
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Using Specific Versions of an APIAdaptive code techniques are not only for handling device family-specific codeYou write your app against a base UWP version but 6 months later UWP vNext ships to users machinesApplies to Extension SDKs and Packages as well ndash new versions may offer new functionality
You want to keep supporting customers who havenrsquot updated yet but take advantage of up-level APIs for those who have
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Package DependencyltDependenciesgt ltPackageDependency Name=MicrosoftWinJS 10 Publisher=CN=Microsoft Corporation O=Microsoft Corporation L=Redmond S=Washington C=US
minVersion =1500 gtltDependenciesgt
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Gate use of up-level APIsvar contract = DevicesScannersScannerDeviceContractint majorVersionRequired = 3
if (WindowsFoundationMetadataApiInformation IsApiContractPresent(contract majorVersionRequired ))
Call the API that is present in V3 and above else Your original code supporting users who havenrsquot upgraded yet
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
What about Shared Projects
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
What about shared projectsShared Projects share code at the code level pre-compilationShare with Windows 81 projects Xamarin projects anythinghellip
Still completely supportedif Compilation directives used to conditionally include code by those projects referencing the Shared Project
1 WINDOWS_APP2 WINDOWS_PHONE_APP3 WINDOWS_UAP (new)
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Use Adaptive Code in Shared tooif WINDOWS_PHONE_APP Processing for Windows Phone 81 only
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
elif WINDOWS_UAP Processing for Windows UWP ndash Desktop AND Mobile if (WindowsFoundationMetadataApiInformation IsTypePresent(WindowsPhoneUIInputHardwareButtons)) But this is only for UWP AND Mobile
WindowsPhoneUIInputHardwareButtonsCameraPressed += thisCamera_Pressed
endif
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Tile basics
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Basic State
Plate
App LogoShort Name
Plate
App Logo
Short Name
Semi-Live State
Plate
App LogoShort NameBadge
Plate
App Logo
Short Name
Badge
Live State
Plate
App IconShort Name
Badge
Content
Plate
Short Name
BadgeApp Icon
Content
Tile anatomy
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Updating tilesScheduledSet template and time with ldquoScheduledTileNotificationrdquo
PeriodicPull from URL 30m 60m 6h 12h 24h
LocalUpdate from (foregroundbackground) app
PushUse push servicesUpdate badge
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Update tile badge build badgevar type = BadgeTemplateTypeBadgeNumbervar xml = BadgeUpdateManagerGetTemplateContent(type)
update elementvar elements = xmlGetElementsByTagName(badge)var element = elements[0] as WindowsDataXmlDomXmlElementelementSetAttribute(value 47)
send to lock screenvar updator = BadgeUpdateManagerCreateBadgeUpdaterForApplication()var notification = new BadgeNotification(xml)updatorUpdate(notification)
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Responsive tilesTiles are not always the same sizeTiles adapt tothe screen they are onSince the Start grid has different densities and adapts to the screen size of your device so do our tiles and the content within them
High density exampleLow density example
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Tile templates
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Legacy templatesIf a template meets your needs go ahead and use it Previous templates remainPhone and Windows templates have been mergedThere are over 80 templates available
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Create a secondary tilevar tileId = DetailsTilevar pinned = SecondaryTileExists(tileId)
if (pinned) var tile = new SecondaryTile(tileId) DisplayName = Record details Arguments = 123
extra details var success = await tileRequestCreateAsync()
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Use secondary tiles to deep-link into your app
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Adaptive templates
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgt ltbinding template=TileMediumgt ltgroupgt ltsubgroupgt lttext hint-style=subtitlegtJohn Doelttextgt lttext hint-style=subtlegtPhotos from our triplttextgt lttext hint-style=subtlegtThought you mighthelliplttextgt ltsubgroupgt ltgroupgt ltgroupgt ltsubgroupgt hellip ltsubgroupgt ltgroupgt ltbindinggt ltvisualgtlttilegt Min Med Size Max Med Size
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Adaptive tileslttilegt ltvisualgtltbinding template=TileMediumgt ltimage source=Assetsimagepng placement=background gt
lttext hint-wrap=truegtMicrosoft HoloLens A Sensational Vision of the PCrsquos Future
lttextgtltbindinggt ltvisualgtlttilegt
Min Med Size Max Med Size
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Adaptive samples
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Sample Small Tile
ltbinding template=TileSmall
branding=none hint-textStacking=centergt
ltbindinggt
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Sample 1 Medium Tileltbinding template=TileMedium branding=Name displayName=Hipstamegt
lttext hint-style=captiongt 950 AM Wednesdaylttextgt
lttext hint-style=captionsubtle hint-wrap=truegt 263 Grove St San Francisco CA 94102lttextgt
ltbindinggt
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Sample Wide Tileltbinding template=TileWide displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgtltbindinggt
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Sample Large Tileltbinding template=TileLarge displayName=Hipstamegt ltgroupgt ltsubgroup hint-weight=33gt ltimage placement=inline src=httpimagejpg gt ltsubgroupgt ltsubgroupgt lttext hint-style=captiongt 950 AM Wednesdaylttextgt lttext hint-style=captionsubtle hint-wrap=true hint-maxLines=3gt 263 Grove St San Francisco CA 94102lttextgt ltsubgroupgt ltgroupgt ltimage placement=inline src=httpmapjpggtltbindinggt
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
AdaptiveTemplates
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Application lifecycle
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
App Lifecycle wersquove had already with Windows 81
Runningapp
Suspendedapp
Suspending Terminatedapp
Low memory
Resuming
Background task executes
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
The resultPredictable behavior on every Windows device
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Application LifetimeRunning Suspended Running Suspended Not Running
Launched Suspended(5 seconds)
Activated Suspended(5 seconds)
Mem
ory
Terminated(no event)
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Important note Desktop device-family apps suspend when they are minimized
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Handling suspensionpublic App() thisInitializeComponent()
thisSuspending += (s e) =gt Save data
thisResuming += (s e) =gt Load data
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Navigation stateFrameGetNavigationState()FrameSetNavigationState()Recommended to use strings as parameters
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
OnNavigatedFrompublic override Task OnNavigatedFromAsync(IDictionaryltstring objectgt state bool suspending) if (suspending) state[FirstName] = thisFirstName state[LastName] = thisLastName state[Email] = thisEmail return TaskFromResultltobjectgt(null)
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
OnNavigatedTopublic override void OnNavigatedTo(string parameter NavigationMode mode IDictionaryltstring objectgt state) try thisFirstName = state[FirstName]ToString() thisLastName = state[LastName]ToString() thisEmail = state[Email]ToString() finally stateClear()
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOHandle suspend
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Extended executionWin10
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Extended executionRequesting extended executionThere is no guarantee resources are availableExtended execution has no UI
Scenario ldquoI have data this timerdquoHandle the Revoked event (1 second warning)
Scenario ldquoIrsquom a special kind of apprdquoThese apps run indefinitely
Special kinds of apps1Turn-by-turn (location tracking) app2Audio amp VOIP application
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
There is a balance between load speed amp shutdown time
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Extended execution (type 1)M
emor
y
Running Extend
Suspended(5 seconds)
Request Revoked(1 second)
Suspended
No UI(short)
Suspended(No event)
Whensuspendin
g
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Requesting extension in suspendprivate async void OnSuspending(object sender SuspendingEventArgs args)
var deferral = argsSuspendingOperationGetDeferral() using (var session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonSavingData ) sessionDescription = Upload Data sessionRevoked += (s e) =gt Log(Save incomplete)
try if (await sessionRequestExtensionAsync() == ExtendedExecutionResultDenied) takes 3 seconds UploadBasicData() else takes 8 seconds await UploadDataAsync(session) Log(Save complete) catch Log(Save failed) finally deferralComplete()
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Extend the suspension of a foreground app
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Extended execution (type 2)M
emor
y
Running Extend
Navigateaway
Special Request(during runtime)
Revoked(1 second)
Suspended
No UI(long running)
Suspended(No event)
Automaticextension
Whenrunning
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Prevent the terminationof a foreground app
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Requesting extension in appprivate async void InvokeMyExtension() if (this_session == null) this_session = new ExtendedExecutionSession Reason = ExtendedExecutionReasonLocationTracking this_sessionDescription = ldquoDriving directions
if (await this_ sessionRequestExtensionAsync() == ExtendedExecutionResultAllowed) todo approved else todo denied
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Enum VALUES[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionReason Unspecified = 0 LocationTracking = 1 SavingData = 2
[ContractVersion(typeof(UniversalApiContract) 65536)]public enum ExtendedExecutionResult Allowed = 0 Denied = 1
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
The global pool supports burst events
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOExtended execution
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
App to App in Windows 81
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
LauncherLaunchUriAsync(new Uri(sampleappID=aea6))
LauncherLaunchFileAsync(file)
App to App in Windows 81URIProtocol Activation
Data in UriFile
UserOS chooses target
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
App to App in Windows 81Share Contract
DataTransferManagerShowShareUI()
Share DataPackage
User chooses target
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
App to App in Windows 10 UWP
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Enhanced App to App in Windows 10
Send file token send data
Launch a specific app
App Services
Launch for Results
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
URI Activation++Invoke a specific app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options)
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
URI Activation++Send Files
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919InstapaperIt
var token = SharedStorageAccessManagerAddFile (gpxFile)
ValueSet inputData = new ValueSet()inputDataAdd(Token token)
var launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriAsync(launchUri options inputData)
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Query URI SupportDiscover if app already installed to handle a Uri
var queryUri = new Uri(instapaper)await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUri)
var queryUri = new Uri(instapaper)string packageFamilyName = 24919InstapaperIt await LauncherQueryUriSupportAsync(queryUri LaunchUriTypeLaunchUriForResults packageFamilyName)
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
App Services
Client App A
Client App B Background Task
App with App Service
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
URI Activation for Device SettingsCategory Settings page Mobile andor
Desktop Uri
System
Display (on desktop)Screen (on mobile) Both ms-settingsscreenrotation
Notifications Both ms-settingsnotifications
Storage Sense Both ms-settingsstoragesense
Battery Saver Both ms-settingsbatterysaver
Maps Both ms-settingsmaps
Devices Bluetooth Both ms-settingsbluetooth
Network and Wi-fi
Wi-Fi Both ms-settingsnetworkwifi
Airplane mode Both ms-settingsnetworkairplanemode
Cellular Both ms-settingsnetworkcellular
Data Sense Both ms-settingsdatasense
NFC Mobile only ms-settingsproximity
Proxy Desktop only ms-settingsnetworkproxy
Morehellip [See documentation for complete list]
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMO
URI Activation in UWP
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Launch for ResultsLaunching the app
var options = new LauncherOptions()optionsTargetApplicationPackageFamilyName = 24919Instapvar launchUri = new Uri(instapaperAddUrl=http3A2F2Fbingcom)await LauncherLaunchUriForResultsAsync(launchUri options data)
var resultData = new ValueSet()resultDataAdd(Result value)operationProtocolForResultsOperationReportCompleted(resultData)
App1 App2
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOLaunch for Results
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
With App Services store applications can provide services to other store applications
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
What are App ServicesUWP offers many APIs that allow apps to interact with the platformbull WindowsApplicationModelContactsbull WindowsApplicationModelEmailbull WindowsSystemLauncherLaunchUriAsync to launch settings maps
store etchellipbull morehellip
UWP also allows apps to interact with each otherbull Uri Associations using LaunchUriAsyncbull File associations using LaunchFileAsyncbull Launch for results using LaunchUriForResultsAsyncbull App Services
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Think lsquoWeb Services on devicersquoClient App A
Client App B
Background Task
App with App Service
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Scenario Bar Code Scanning
Bar Code decoding App
ServiceImage bytes in ValueSet or FileToken
Decoded data
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Scenario Enterprise suite of apps
App ServiceMaintains Inventory
cache
Client App A
Client App B
Interact with cloud services
App ServiceProximity Reading
Services
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
AppServiceConnection connection = new AppServiceConnection()connectionAppServiceName = microsoftDX-appservicesdemoconnectionPackageFamilyName = 24919ArunjeetSinghInstapaperIt
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) Send data to the service var message = new ValueSet() messageAdd(Command CalcSum) messageAdd(Value1 Int32Parse(Value1Text)) messageAdd(Value2 Int32Parse(Value2Text))
Send message and wait for response AppServiceResponse response = await connectionSendMessageAsync(message) if (responseStatus == AppServiceResponseStatusSuccess) int sum = (int)responseMessage[Result] new MessageDialog(Result= + sum)ShowAsync() else Drive the user to store to install the app that provides the app service
App Services ndash Client
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
namespace AppServicesDemoTask public sealed class AppServiceTask IBackgroundTask private static BackgroundTaskDeferral _serviceDeferral
public void Run(IBackgroundTaskInstance taskInstance) Associate a cancellation handler with the background task taskInstanceCanceled += TaskInstance_Canceled
Get the deferral object from the task instance _serviceDeferral = taskInstanceGetDeferral()
var appService = taskInstanceTriggerDetails as AppServiceTriggerDetails if (appServiceName == microsoftDX-appservicesdemo) Maybe ValidateCaller(appServiceCallerPackageFamilyName) appServiceAppServiceConnectionRequestReceived += RequestReceived
App Services ndash Service (12)
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
private async void RequestReceived(AppServiceConnection sender AppServiceRequestReceivedEventArgs args) var message = argsRequestMessage This service uses a Command keyed entry for the client to invoke services from the App Service string command = message[Command] as string switch (command) case DoIt var messageDeferral = argsGetDeferral() int value1 = (int)message[Value1] Do some processing
Set a result to return to the caller var returnMessage = new ValueSet() returnMessageAdd(Result result) var responseStatus = await argsRequestSendResponseAsync(returnMessage) messageDeferralComplete() break case Quit Service was asked to quit Complete service deferral so platform can terminate _serviceDeferralComplete() break
App Services ndash Service (22)
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Declaring App Serviceltxml version=10 encoding=utf-8gtltPackage xmlns=httpschemasmicrosoftcomappxmanifestfoundationwindows10 gt
ltApplicationsgt ltApplication Id=Appldquo gt ltExtensionsgt ltuapExtension Category=windowsappServiceldquo EntryPoint=AppServicesDemoTaskAppServiceTaskgt ltuapAppService Name=microsoftDX-appservicesdemo gt ltuapExtensiongt ltExtensionsgt ltApplicationgt ltApplicationsgt
ltCapabilitiesgt ltCapability Name=internetClient gt ltCapabilitiesgtltPackagegt
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
Two-way CommunicationClient and server can keep a two-way chatty communication channel openClient can attach a RequestReceived event handler to its own AppServiceConnection instance
Both client and server can send and receive messages
AppServiceConnectionStatus connectionStatus = await connectionOpenAsync()if (connectionStatus == AppServiceConnectionStatusSuccess) connectionRequestReceived += OnRequestReceived
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
DEMOApp Services
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
httpwindowsMicrosoftcom
SummaryWindows 10 allows for REAL universal appsKnowledge of WinRT is still very relevant
Letrsquos enjoy Windows 10hellipand some BBQ
Letrsquos enjoy Windows 10hellipand some BBQ
Recommended