I’m speaking at DDD Sydney

The “Developer Developer Developer” conferences have consistently been a great event. If you are in Sydney be sure to purchase your ticket and come this weekend! It is only $25 for a full day of talks, food & giveaways.

http://www.dddsydney.com

I’m also proud to say that I’ll be speaking this year on Windows 8 Development 101: The basics of XAML and ViewModels
The Windows 8 platform will soon allow people to build “Metro style applications” and sell them on the Windows Marketplace.
Join David Burela as he takes anyone who is new to Desktop development through the basics of developing for Windows 8. XAML, Databinding, DataTemplates and ViewModels will all be introduced.
Discover how to separate your UI from your business logic, how to create List Views that display your data richly, plus much more.
The techniques here can be applied to any XAML based application: WinRT, WP7, WPF, SL5.

By David Burela

Advertisements

Background tasks in Windows 8 failing instantly

I have seen an instance where trying to instantiate a background task in Windows 8 results in it failing instantly, or throwing an UnauthorizedAccessException.

This happens when you have put the task is in a 2nd project whose build output is set to Class Library. Simply go into the project settings, and change the Output type to WinMD file.

image

By David Burela

My notes from the Windows Phone 8 announcement

Note: the first few screenshots were low quality, the later images are fine once the connection improved. I’ll update the images once the session is downloadable

Summary

(click to read more)

Windows 8 demo–Updating application tiles

I have had requests to share the Windows 8 demos that I gave at the Windows 8 Developer camp. The source code is available on Github at https://github.com/DavidBurela/Win8Demo-Tiles

Text tile

Application tiles in your application can be updated by sending a formatted XML message to the TileUpdateManager. The easiest way to achieve this is to get a base template for the tile style that you want (Text only, Image, Image and Text, etc) then modifying the Text or Image elements of the template. The code below shows how a XML template can be taken and updated with custom text. The XML document is then used to create a TileNoficitacion which is then sent to the TileUpdateManager.

/// <summary>
/// Set the application's tile to display text content.
/// After clicking, go back to the start screen to watch your application's tile update.
/// </summary>
private void SetTileTextButtonClick(object sender, RoutedEventArgs e)
{
    // Tiles use a predefined set of standard templates to display their content.
    // The updates happen by sending a XML fragment to the Tile update manager.
    // To make things easier, we will get the template for a square tile with text as a base, and modify it from there
    var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText01);

    // Find the 'text' element in the template's XML, and insert the text "Hi :-)" into it.
    var elements = tileXml.GetElementsByTagName("text");
    elements[0].AppendChild(tileXml.CreateTextNode("Hi :-)"));

    // Create a TileNotification from our XML, and send it to the Tile update manager
    var tileNotification = new TileNotification(tileXml);
    TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
}

Image tile from local image file

It is also possible to create the XML from scratch and send it to the TileUpdateManager. The code below updates the application tile with an image tile. It starts by instantiating a XmlDocument, creating each of the XML elements, and then chaining the elements together to form the final XML document. The path to the image is given as being a local application resource through the convention ms-appx:///Assets/DemoImage.png

/// <summary>
/// Set the application's tile to display a local image file.
/// After clicking, go back to the start screen to watch your application's tile update.
/// </summary>
private void SetTileImageButtonClick(object sender, RoutedEventArgs e)
{
    // It is possible to start from an existing template and modify what is needed.
    // Alternatively you can construct the XML from scratch.
    var tileXml = new XmlDocument();
    var title = tileXml.CreateElement("title");
    var visual = tileXml.CreateElement("visual");
    visual.SetAttribute("version", "1");
    visual.SetAttribute("lang", "en-US");

    // The template is set to be a TileSquareImage. This tells the tile update manager what to expect next.
    var binding = tileXml.CreateElement("binding");
    binding.SetAttribute("template", "TileSquareImage");
    // An image element is then created under the TileSquareImage XML node. The path to the image is specified
    var image = tileXml.CreateElement("image");
    image.SetAttribute("id", "1");
    image.SetAttribute("src", @"ms-appx:///Assets/DemoImage.png");

    // All the XML elements are chained up together.
    title.AppendChild(visual);
    visual.AppendChild(binding);
    binding.AppendChild(image);
    tileXml.AppendChild(title);

    // The XML is used to create a new TileNotification which is then sent to the TileUpdateManager
    var tileNotification = new TileNotification(tileXml);
    TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
}

Image tile from remote image

A remote image can be used by again using a template (or hand crafting the XML from scratch as in the previous example), but this time providing a URI to an image hosted on a remote web server, rather than a local application resource.

/// <summary>
/// Set the application's tile to display a remote image on the internet.
/// After clicking, go back to the start screen to watch your application's tile update.
/// </summary>
private void SetTileRemoteImageButtonClick(object sender, RoutedEventArgs e)
{
    var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareImage);

    // Find the 'image' element in the template's XML. Change the src attribute to a remote URL
    var elements = tileXml.GetElementsByTagName("image");
    var imageElement = elements[0] as XmlElement;
    imageElement.SetAttribute("src", @"http://i.microsoft.com/global/en-us/homepage/PublishingImages/sprites/microsoft.png");

    // Create a TileNotification from our XML, and send it to the Tile update manager
    var tileNotification = new TileNotification(tileXml);
    TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
}

Again, this source code is available as a working example on Github at https://github.com/DavidBurela/Win8Demo-Tiles By David Burela

Windows 8 developer camp companion application + source code

I put aside a few hours over the weekend and created a companion application for the “Windows 8 developer camps” that are currently running all around Australia. http://www.lalaninja.com.au/2012/03/19/windows-8-developer-camps-australia/

It only took a few hours to throw something simple together for the attendees. The application provides some basic features to help out on the day

  • Daily schedule
  • Dates
  • XDDN details. So that attendees can continue with their Windows 8 learning
  • Links to online Windows 8 developer resources
  • Links to source code of the demos I gave in my presentations (submitted in pending app update)

Download the Windows Phone 7 marketplace right now
http://www.windowsphone.com/en-AU/apps/1a7853b1-1d2c-4d1c-9ba1-6d709053eced

I have made the source code available for anyone that wants to see how a simple app can be put together in only a few hours and submitted to the marketplace.
https://github.com/DavidBurela/Windows8DeveloperCampPhoneApplication

scheduleXDDN informationonline resources

By David Burela

BUILD keynote day 1–Metro experience with Jupiter, XAML and HTML5/JS

Highlights

  • You can download the developer preview of Windows 8
    http://dev.windows.com/
    http://blogs.msdn.com/b/b8/archive/2011/09/13/welcome-to-windows-8-the-developer-preview.aspx
  • The confusion around HTML5, xaml and Jupiter is finally cleared up.
    The new immersive apps (full screen, metro style apps which are launched from the tile based interface) can be built in either C#/XAML or HTML5/JS. Under the covers it reflects into the WinRT APIs. Apps built like this will run on ANY Win8 machine (x86, ARM, etc)
    clip_image001[4]
  • Silverlight & WPF are “legacy”. They put it onto the slide for show. The Win8 xaml looks to be 90% compatible with Silverlight. Demos are shown where they take a Silverlight app, copy/paste the code into a new Win8 XAML app, and only a few namespaces need to be changed. A silverlight grid is then changed to use the native WinRT grid to make it touch enabled and “Metro-y”
  • The Win8 XAML app is ported to Windows Phone 7 with only 1 line changed.
  • New version of Visual Studio available to help build apps for Win 8 “Microsoft Visual Studio 11 Express for Windows Developer Preview” (got to love Microsoft product names)
  • Expression blend works for editing the HTML5/JS apps
  • The native WinRT controls work in XAML and HTML5
  • New windows 8 app store. Store & submission process VERY similar to Windows Phone 7. Can submit via Visual Studio
    Paul Thurrott: “Biggest point of Windows Store: Microsoft is NOT taking a 30 percent cut. It will take a ZERO percent cut.”
  • Win8 machines can be easily restored back to a “clean base image” that developer can specify. Keeps all files, just reverts apps. (Reset/Refresh)
  • Windows Live application integration. Nice support for photos, calendar, mail, people. Very similar to Windows Phone 7 built in features.
    Windows user account settings Synced across PCs via the cloud (profile photo, etc)
  • Win8 specs are the same as Win 7. Consumes less memory after startup.
    Boot times have been massively reduced. Cold boot demo shows the PC almost starting faster than the monitor can turn on.

Useful articles

Continue reading

Premature cries of Silverlight / WPF skill loss. Windows 8 supports all programming models

UPDATE: The BUILD keynote cleared up a LOT of these concerns https://davidburela.wordpress.com/2011/09/14/build-keynote-day-1metro-experience-with-jupiter-xaml-and-html5js/

Summary

  • Windows 8 supports applications being built in C# / XAML / VB.Net / C++ / HTML+JS.
  • The new UI framework ‘Jupiter’ allows applications to be written in your language of choice. This is similar to how the .Net framework allowed people to code against the framework in their language of choice.
  • Jupiter seems to be a ‘Next generation’ XAML based framework
  • I’m more excited about the new possibilities coming in the new Jupiter XAML programming model than the misconception that HTML+JS is the only way to create apps.

History

In the last few weeks, the internet has been in frenzy over the newly released demo video of Windows 8. In the video there is only mention of the new “Immersive applications” being created in a mixture of HTML + Javascript. People took this as more evidence that WPF & Silverlight are dead. Which hasn’t helped after the lack of attention which caused events like Silverlight Firestarter to be needed, or the http://FixWPF.org movement. It also doesn’t help when Microsoft have remained tight lipped even after an outcry from developers. The famous thread on the Silverlight forums has seen over 13,000,000 views. Which is more than the forums usually see in a single month.

The windows 8 UI demo video

Digging into the Windows 8 leak

A few people have been digging into the Windows 8 Milestone 3 leak and peeking into the UI framework and .dlls that exist. The most vocal of these have been @JoseFajardo and people in this forum thread http://forums.mydigitallife.info/threads/26404-Windows-8-(7955)-Findings-in-M3-Leak

What people have found so far is that while yes it is possible to create applications using HTML + Javascript, there is a whole new framework laying underneath that can be programmed against by almost any language / framework.

The first piece of the puzzle comes from the new application model for creating applications. There are a number of codenames here that need to be sorted out

  • DirectUI: The underlying framework that creates, draws the visual elements on the screen.
  • Jupiter: The new packaging format of applications on Windows 8. Allows apps to be written in language of choice.
  • Immersive applications: Current theory is that these are apps that execute within the ‘new shell’ in windows 8. And are aware of being split paned and resized. Like was shown with the RSS feed reader.

Direct UI

Direct UI has been around since Windows Vista days. Previous is seemed to be focused around UI basics for the OS such as theming app windows in the ‘new vista style’ vs. classic theming in WinXP. http://blog.vistastylebuilder.com/?tag=directui

Now it seems that Direct UI is being overhauled to have additional functionality to load XAML applications, new animations, etc.

Xaml loader

330fv43[1]
http://i54.tinypic.com/330fv43.png
http://forums.mydigitallife.info/threads/26357-Findings-in-M3-Leak-discussion-and-questions?p=421391&highlight=silverlight#post421391

Evidence of new animation properties

http://pastebin.com/S1XtkQid

Jupiter

interesting rumor fact : WP8 rumored to be codenamed Apollo, and Apollo is the son of Jupiter 🙂 Jupiter being the new UI framework of Win8
http://twitter.com/#!/josefajardo/status/78826337250451457

…Jupiter is shaping up to be a very very lean SL/WPF implementation
http://twitter.com/#!/josefajardo/status/79423110755008512

…your SL/WPF skills will be invaluable for DirectUI apps, and you get a new framework that is seriously lean!!!
http://twitter.com/#!/josefajardo/status/79425349938712577

DirectUI.dll is basically Silverlight (agcore.dll) ported to Windows/WinRT
http://forums.mydigitallife.info/threads/26404-Windows-8-(7955)-Findings-in-M3-Leak?p=441627#post441627

Jose Fajardo has been a great source of information on Windows 8 leaks. From information he has dug up, as well as information on the forums, it seems that the new Jupiter programming API is a mashup between WPF & Silverlight.

As far as I can see, Jupiter is not Silverlight nor WPF, its another kind of framework that kinda similar or compatible to Silverlight/WPF code.
So Sinofsky is right, that ‘Silverlight’, as we know it, is still a Browser/Desktop thing.
What he didn’t say is, the ‘Jupiter’ framework will enable you to leverage your Silverlight/.NET skills to write Immersive (or desktop) applications in XAML/C#/VB/C++, its very very similar, but not exactly the same thing.
The situation is similar to the relationship of Silverlight and WPF and Silverlight for Phone, you need to create different project in VS, then you can write very similar UI/code, even sharing most of your portable code in a common library, but the underlying technology are still very different.

https://channel9.msdn.com/Forums/Coffeehouse/Jupiter/e7960a6237024c1598639efc00d8e394

While the new Jupiter programming model may not be a direct continuation of WPF or Silverlight it does seem to have a lot of code from both technologies. Jupiter instead seems to be a ‘Next generation’ XAML based framework. A framework that can be targeted against by all main current languages used by the typical .Net developer (C#, HTML, etc)

*speculation* This could be because of the calls from the development community to make WPF & Silverlight more aligned. Perhaps we’ll see an updated ‘Silverlight’ framework when Windows Phone 8 is released that is compatible with Jupiter.

Creating applications with Jupiter

As further evidence that Jupiter applications can be created with your language of choice, and that it has roots in Silverlight, here are some examples of how to create applications.

C# & XAML

Here is an example of using C# to invoke a new Jupiter based application. The really interesting thing to notice here is that the loading screen has the iconic Silverlight loading animation!
4437[1]
http://xs.to/photo/4437
http://forums.mydigitallife.info/threads/26404-Windows-8-(7955)-Findings-in-M3-Leak?p=444628&viewfull=1#post444628

Here is a second example where they were able to get XAML content to load within a Jupiter application
5196[1]
http://c592786.r86.cf2.rackcdn.com/anonym/2011/06/11/5196.png
http://forums.mydigitallife.info/threads/26404-Windows-8-(7955)-Findings-in-M3-Leak?p=445016&viewfull=1#post445016

*update* Naive User was able to get simple databinding working
9126[1]
http://c592786.r86.cf2.rackcdn.com/anonym/2011/06/14/9126.png
http://forums.mydigitallife.info/threads/26404-Windows-8-(7955)-Findings-in-M3-Leak?p=446590&viewfull=1#post446590

C++

Example of an application being created in C++ with a single call to CreateImmersiveWindowFunc
3852[1]
http://xs.to/photo/3852
http://forums.mydigitallife.info/threads/26404-Windows-8-(7955)-Findings-in-M3-Leak?p=444200&viewfull=1#post444200

HTML + Javascript

There are some initial attempts at getting HTML working with the new frameworks. The apps and manifests have been created, but a few more hooks may be required to get a fully working version
http://forums.mydigitallife.info/threads/26404-Windows-8-(7955)-Findings-in-M3-Leak?p=446552&viewfull=1#post446552

There are mentions that you can hooks into Direct UI through the COM hooks from Javascript. And also that you may be able to use Direct UI XAML + Javascript. Similar to how Silverlight was done in the original Silverlight version 1.

Immersive applications

There is some confusion over the distinction between a “Jupiter app” and an “Immersive app”. Immersive apps require a call to CreateImmersiveWindow and can make calls to the new immersive namespace

6941[1]
http://c592786.r86.cf2.rackcdn.com/anonym/2011/06/13/6941.PNG

Immersive applications are ones that were shown to live inside of the new Windows 8 shell. Examples of functions that an immersive app can do can be seen with the RSS reader app. When it was docked and resized, it knew to display its data in a different format.

  • Classic / Jupiter applications will run in the ‘classic windows’ desktop view that was seen when they fired up excel
  • Immersive applications will be embedded within the new shell

Will this work for existing applications?

There is evidence that existing applications can be wrapped up in the new packaging format.

WindowsStore is basically written in C++ and leverages Windows Runtime. HTML5/JavaScript is just a (very very) thin layer for the interface
http://forums.mydigitallife.info/threads/26404-Windows-8-(7955)-Findings-in-M3-Leak?p=442463&viewfull=1#post442463

So while existing applications may not run with the new Direct UI framework, it seems they will still be able to be packaged and distributed through the Windows 8 App store. This was discovered by Long Zheng a few months ago.

The AppX format is universal enough so it appears to work for everything from native Win32 applications to framework-based applications (WPF, Silverlight) and even *gasp* web applications. Games are also supported.
http://www.istartedsomething.com/20110405/first-look-at-the-future-of-application-deployment-on-windows-8-appx/

Conclusion

While Microsoft only showed off the HTML hooks into Jupiter, I am a LOT more excited about the upcoming XAML based framework.

If you are an existing WPF, Silverlight or Windows Phone 7 developer, it seems that your XAML based skills will carry across fine to the new development framework on Windows 8.

My thoughts are that Microsoft announced that applications can be created in HTML in the same way that they announced it in WindowsXP with active desktop, and then again in Vista with “HTML based sidebar gadgets”. It was a way of saying “hey you can use your existing web skills to create applications on Windows 8.
And that Microsoft plans on unveiling the new Jupiter SL/WPF hybrid framework for all of the “Real developers” at BUILD in 3 months.

By David Burela